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
  • 41,304
  • 47
  • 143
  • 239

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
  • 81,403
  • 31
  • 214
  • 233