0

For reference, the Bash equivalents are discussed here: Check if a program exists from a Bash script

I've been doing something like

if `which commandname` =~ /commandname/
  # do stuff
end

but I'm wondering if there is something a little cleaner.

Community
  • 1
  • 1
dan
  • 43,914
  • 47
  • 153
  • 254

1 Answers1

2
system("ls")
#=> true

system("ls wrong params")
#=> false

system("lss")
#=> nil

if system("your cmd")
  puts "yey!"
else
  puts "oups"
end
fl00r
  • 82,987
  • 33
  • 217
  • 237