Sha256: adf30182d9d8538efc83b397c9ea281272713e11dbbccfd7cf9e6ab18d043d27

Contents?: true

Size: 951 Bytes

Versions: 86

Compression:

Stored size: 951 Bytes

Contents

#!/usr/bin/env ruby

require 'tins/go'
include Tins::GO
require 'tins/xt/secure_write'
require 'tempfile'

path_separator = RUBY_PLATFORM =~ /mswin32/ ? ';' : ':'
path = (ENV['PATH'] || '').split(path_separator)
path.map! { |part| File.expand_path(part) }

$opt = go('e')

case cmd = ARGV.shift
when 'prefix', 'postfix'
  part = ARGV.shift or fail 'need a path part to prefix'
  part = File.expand_path(part)
  path.delete part
  if cmd == 'prefix'
    path.unshift part
  else
    path.push part
  end
when 'edit'
  if path_argument = ARGV.first
    path = path_argument.split(path_separator)
    path.map! { |part| File.expand_path(part) }
  end
  path_file = File.join(Dir.tmpdir, "path_temp.#$$")
  File.secure_write path_file, path * "\n"
  system "edit -w #{path_file.inspect}"
  path = File.read(path_file).split(/\n/)
  path.map! { |part| File.expand_path(part) }
end

path.uniq!

puts "#{'export ' if $opt['e']}PATH=#{path * path_separator}"

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
utils-0.2.4 bin/path
utils-0.2.3 bin/path
utils-0.2.2 bin/path
utils-0.2.1 bin/path
utils-0.2.0 bin/path
utils-0.1.1 bin/path
utils-0.1.0 bin/path
utils-0.0.100 bin/path
utils-0.0.99 bin/path
utils-0.0.98 bin/path
utils-0.0.97 bin/path
utils-0.0.96 bin/path
utils-0.0.95 bin/path
utils-0.0.94 bin/path
utils-0.0.93 bin/path
utils-0.0.92 bin/path
utils-0.0.91 bin/path
utils-0.0.90 bin/path
utils-0.0.89 bin/path
utils-0.0.88 bin/path