From: Robert Klemme Date: 2003-04-11T16:07:18+09:00 Subject: Re: parsing ENV['PATH'] "Peter Ensch" schrieb im Newsbeitrag news:b74oo5$h0f$1@tilde.itg.ti.com... > What am I doing wrong here? > > ENV["PATH"].split(':').each { |i| > puts i > # do more stuff here > } First of all you should use File::PATH_SEPARATOR to make it more portable like in ENV["PATH"].split(File::PATH_SEPARATOR).each { |i| puts i # do more stuff here } Additionally you could eliminate empty paths by doing: ENV["PATH"].split(File::PATH_SEPARATOR).reject{ |d| d=="" }.each { |i| puts i # do more stuff here } or even ENV["PATH"].split(Regexp.new(File::PATH_SEPARATOR+"+")).each { |i| puts i # do more stuff here } > My PATH env. variable is a long list of ':' separated > paths; however ENV['PATH'] only sees the first path. > > So, the 'split' works fine, it's the initial string I'm > splitting that is the problem. > > I know I'll feel dumb once I know the answer. To make sure that ENV["PATH"] yields what you expect I'd include a puts statement at the beginning of the script. If you are working on Win with cygnus bash then the shell tries to do some smart conversions between Unix and Windows PATH separator conventions which may lead to surprising results. Robert