Robert Klemme
10/29/2006 6:40:00 PM
Andreas S <andreas_s@hotmail.com> wrote:
> I can't any information about this, so I dare myself to post here. I
> have shell script I want to call from ruby, say testme.sh, where it
> contains
> echo "It's me"
>
> Calling it with %x{testme.sh} gives me the expected result, but
> calling it with backtick `testme.sh` results in 'command not found:
> testme.sh'.
> The backtick works if I put double quotes around it, ie
> `"testme.sh"`, or if I use shebang in the shell script
> #!/bin/sh
> echo "It's me"
>
> Why is this? By the way `testme.sh` works in perl which made me
> expect it to work in ruby too (I know, I know, I shouldn't expect
> that).
IMHO without #! all bets are off. AFAIK every shell tries to execute a
script itself if it cannot be exec'ed as a binary. This can lead to
problems if a csh tries to execute a sh script or vice versa. So basically
you should *always* use the shebang line to make clear which interpreter is
supposed to execute a script - even if "it works without" and you do it only
for documentation reasons. If adding the shebang line fixes it I'd just do
that and not bother any more. My 0.02EUR
Kind regards
robert