I have a bunch of shell scripts which incorrectly assume /bin/sh
to be equivalent to /bin/bash
. E.g., they have the #!/bin/sh
shebang, but use the source
command instead of .
(dot).
I run Ubuntu 16, where /bin/sh
links to dash
, and thus bash-isms are not supported.
I need to run the scripts periodically. Also, from time to time I will need to update them from the original author, who is not into fixing this particular bug. I would like to avoid fixing all these files (there are a bunch of them, they are not mine, and I'll loose all the changes after update). Also, I would like to avoid making global changes to system, since it might potentially break other scripts.
Is there a way to somehow create a (temporary or not) environment with /bin/sh
pointing to bash, to be used for these scripts, while not touching the global system /bin/sh
?
/bin/sh
! You have no way to know which other programs, scripts and so on rely on /bin/sh (a lot!), and this may seriously break your system. Instead, fix your shell scripts! – mhutter Sep 12 '18 at 00:06/bin/sh
. – Alex Che Sep 12 '18 at 10:32/bin/sh
is the same as/bin/bash
?!?!?! Who are these, ummm, not-as-smart-as-they-think-they-are maintainers? So I can avoid anything written by them in the future? Tell them to read some of the links in this Google search: https://www.google.com/search?q=sh+is+not+bash – Andrew Henle Sep 12 '18 at 10:54/bin/sh
and accepting software that assumes/bin/sh
is the same as/bin/bash
is how you get systems that continually fail and are unmaintainable. Your acceptance of such incompetence directly contributes to "a world which is not ideal". – Andrew Henle Sep 12 '18 at 11:11