Sometimes it happens that for one reason or another there's a need to use a proprietary application (read: can not be modified due to its licence) that contains bashisms. Since the application can not be modified and it might not be desirable to change the default /bin/sh, dealing with such applications can be a pain. Or not.
The
switchsh program (available in Debian) by
Marco d'Itri can be used to execute said application under a namespace where bash is bind-mounted on /bin/sh. The result:
$ sh --help
sh: Illegal option --
$ switchsh sh --help | head -n1
GNU bash, version 4.1.5(1)-release-(i486-pc-linux-gnu)
Simple, yet handy.
Also bad: stuff that writes bash-only crap into /etc/profile.d/ such as ruby-rvm (which basically is proprietary software, considering the usual install method is “curl | sudo bash” which makes my toes curl). Since that affects login shells, not /bin/sh, a different fix is needed (such as not using Ruby at all).
ReplyDelete