From: Stefano Mioli Date: 2010-10-20T05:02:51+09:00 Subject: Separator in $PATH Hello everyone, Unix-like operating systems use a colon to separate each directory in the PATH, while Windows uses a semicolon. The question is: is there some class in the Ruby library that knows about this difference? Or do I have to resort to something like the following? if RUBY_PLATFORM =~ /(win|w)32$/ # ... end I'm asking this question because I need to figure out if a given executable is in the path and, if it does, retrieve its full path. So I whipped up this one-liner which seems to work as expected (except on Windows, of course): ENV["PATH"].split(":").collect {|p| File.join(p, "foo")}.keep_if{|p| File.exist? p}.first where "foo" is the name of the executable. While we're at it, can someone think of a better / more idiomatic way to do it? Obviously, simply trying to run the executable is not an option. Thanks in advance. -- Stefano