In the description of the command output expression, we said that the
string in backquotes would ``by default'' be executed as a command. In
fact, the string is passed to the method called
Kernel::`
(a single backquote). If you want, you can override
this.
alias oldBackquote `
def `(cmd)
result = oldBackquote(cmd)
if $? != 0
raise "Command #{cmd} failed"
end
result
end
print `date`
print `data`
|
produces:
Sun Jun 9 00:08:26 CDT 2002
prog.rb:3: command not found: data
prog.rb:5:in ``': Command data failed (RuntimeError)
from prog.rb:10
|