From: Robert Klemme Date: 2008-08-12T15:37:53+09:00 Subject: Re: Sigh! I'm depressed. Debian vs Ruby and the backtick and subshells On 12.08.2008 07:48, John Carter wrote: > 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. You should probably mention that the bug is actually in _your_ code: if you rely on bash features present in /bin/sh then that's the error. :-) Kind regards robert