Да: обновить до ruby 1.9.Если вы запустите это в 1.9, вместо этого будет поднят Errno::ENOENT
, и вы сможете rescue
.
(Правка) Вот хакерский способ сделать этов 1.8:
error = IO.pipe
$stderr.reopen error[1]
pipe = IO.popen 'qwe' # <- not a real command
$stderr.reopen IO.new(2)
error[1].close
if !select([error[0]], nil, nil, 0.1)
# The command was found. Use `pipe' here.
puts 'found'
else
# The command could not be found.
puts 'not found'
end