I have just strace’d weird bug to it’s root cause.
For decades bash was the “sh” of choice for linux systems.
Then somebody threw some money at the Debian foundation to make Debian
boot faster.
The solution was to tweak the init scripts to be perfectly POSIX
Lowest Common Denominator “sh” compatible, and then make dash the
default “sh”.
To allow for legacy scripts that expect /bin/sh === /bin/bash you can
sudo dpkg-reconfigure dash
and switch back to sh === bash
Thus on Debian (and Debian derivatives like Ubuntu) Rubies backtick
(iff there is a glob or a redirection present) is HARDCODED to /bin/sh
but will (depending on the users whim) give you dash or bash.
For example the &> redirection is a bashism…
ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-08-12 16:54 /bin/sh -> dash
build@ws1419:~/AutomatedBuild/test$ ruby -e ‘system(“ls
NOFILEWITHTHISNAME&>foo”)’
ls: cannot access NOFILEWITHTHISNAME: No such file or directory
build@ws1419:~/AutomatedBuild/test$ cat foo
build@ws1419:~/AutomatedBuild/test$ sudo dpkg-reconfigure dash
Removing diversion of /bin/sh to /bin/sh.distrib by dash' Removing
diversion of /usr/share/man/man1/sh.1.gz to
/usr/share/man/man1/sh.distrib.1.gz by dash’
build@ws1419:~/AutomatedBuild/test$ ruby -e ‘system(“ls
NOFILEWITHTHISNAME&>foo”)’
build@ws1419:~/AutomatedBuild/test$ cat foo
ls: cannot access NOFILEWITHTHISNAME: No such file or directory
AAARGH!
As I always say… if a bug is hard to find… you won’t know what to
do with it once you find it.
John C. Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [email protected]
New Zealand