Sha256: 735d77dbe66737bb75106bf03aed3067309105e4bcbf22b634286cf0a4f9be0e

Contents?: true

Size: 951 Bytes

Versions: 20

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) }

$opts = 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

20 entries across 20 versions & 1 rubygems

Version Path
utils-0.22.1 bin/path
utils-0.22.0 bin/path
utils-0.21.2 bin/path
utils-0.21.1 bin/path
utils-0.21.0 bin/path
utils-0.20.0 bin/path
utils-0.19.0 bin/path
utils-0.18.1 bin/path
utils-0.18.0 bin/path
utils-0.17.0 bin/path
utils-0.16.0 bin/path
utils-0.15.1 bin/path
utils-0.15.0 bin/path
utils-0.14.0 bin/path
utils-0.13.0 bin/path
utils-0.12.0 bin/path
utils-0.11.0 bin/path
utils-0.10.1 bin/path
utils-0.10.0 bin/path
utils-0.9.0 bin/path