rescuing a failed %x[] call?

K

Kyle Schmitt

I know it should be streightforward, but I'm not finding the docs anywhere...

How does one go about rescuing a failed shell command? like in the
instance it fails, or the command isn't found?

Thanks,
Kyle
 
A

Avdi Grimm

I know it should be streightforward, but I'm not finding the docs anywhere...

How does one go about rescuing a failed shell command? like in the
instance it fails, or the command isn't found?

According to some experiments in IRB, the failed shell command won't
raise an exception; it will leave a non-zero exit code in the $?
special variable. You'll need to check the value of $? and take
action accordingly.

--
Avdi

Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com
 
K

Kyle Schmitt

According to some experiments in IRB, the failed shell command won't
raise an exception; it will leave a non-zero exit code in the $?
special variable. You'll need to check the value of $? and take
action accordingly.

Advi, the problem is I've got a script failing on a "command not
found", and not continuing onward. I see no amount of fiddling that
can help that.
 
K

Kyle Schmitt

Just tried it... it works fine for me, outputs the "command not found"
message on stderr but keeps right on going... what platform are you
on?

Linux, CentOS/RedHat. Depending on the box it'll be anywhere from
2.1AS all the way through 5.2, so the code is actually run on a rather
wide variety.

--Kyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,979
Members
47,579
Latest member
CharaS3188

Latest Threads

Top