Is there a way to capture a "command not found" error in a Ruby script? For instance, given:
output = `foo`
How do I trap the situation where foo
isn't installed? I expected that I could rescue
an exception, but this doesn't seem to work on 1.8.7. Is there a different way of calling the subprocess that will do what I want? Or is there a different approach?
Update
My apologies, I forgot to mention a hidden requirement: I would prefer that the interpreter doesn't leak the command line to the user (it can contain sensitive data), hence why the exception catching method is preferred. Apologies again for leaving this out the first time.