Strippath.rb
Often I need to remove something off my path. For example, when building certain tools, I don't want Sun's cc compiler present.
Here's a simple ruby script I use to find the program, and display what my path needs to be changed to. <geshi lang="ruby">
- !/bin/env ruby
- a simple script to help clean up one's path.
path = ENV['PATH'].split(':').uniq
args = ARGV.clone while args.size > 0 do
cmd = args.shift type = while !type.match(/not found/) type = `type #{cmd} 2>&1`.chomp if type =~ /(#{cmd}) is (.*)/ then dir = File.dirname($2).to_s puts "removing #{dir}" if !path.delete(dir) then puts "failed to find #{dir} on #{path.join(':')}" exit 1 end ENV['PATH'] = path.join(':') end end
end
puts "export PATH=\"#{path.join(':')}\"" </geshi>