Re:Bash functions are better than I thought
by Spivak on Sunday October 31, 2021 @04:20PM
(#29060028)
Not all sh syntax is valid bash — in bash [[ is reserved but not in sh. And if you want syntax that is valid but doesn’t do the same thing in sh vs bash there’s plenty of examples.
Re:Bash functions are better than I thought
by kevin_thibedeau on Sunday October 31, 2021 @07:49PM
(#29061614)
You can't ever assume that /bin/sh is a POSIX shell so then you get limited to just an early Bourne subset.
Since all valid "sh" syntax is valid "bash", you've got to restrict yourself to only sh-valid code in the event the host doesn't have bash.
I have gotten used to doing this -- these scripts usually wind up being run in Docker containers that don't have "bash" installed for the sake of minimalism.
IE, you can't use [[ $predicate ]], but instead [ $predicate ], etc. Lot of subtle differences.