I recently stumbled upon checkbashisms in devscripts and ran it on the operations/puppet repository:
line 8 (alternative test command ([[ foo ]] should be [ foo ])): if [[ $? -ne 0 ]]; then line 9 (alternative test command ([[ foo ]] should be [ foo ])): if [[ $? -ne 0 ]]; then
line 7 (echo -e): echo -e '\nFound a valid Kerberos ticket in the credential cache:' line 10 (echo -e): echo -e '\nYou do not have a valid Kerberos ticket in the credential cache, remember to kinit.'
line 8 ('function' is useless): function autorenew_is_active { line 12 ('function' is useless): function create_autorenew_timer { line 13 (echo -e): echo -e "\nCreating automatic Kerberos ticket renewal service" line 23 (echo -e): echo -e '\nYou have a valid Kerberos ticket.' line 24 (echo -e): autorenew_is_active && echo -e 'Your automatic Kerberos ticket renewal service is also active on this host\n' || create_autorenew_timer line 26 (echo -e): echo -e '\nYou do not have a valid Kerberos ticket in the credential cache, remember to kinit.'
line 229 ([^] should be [!]): if [ `echo "$warning" | grep [^0-9]` ] || [ ! "$warning" ]; then line 234 ([^] should be [!]): if [ `echo "$critical" | grep [^0-9]` ] || [ ! "$critical" ]; then
line 268 (should be 'b = a'): [ "$num" == "-1" ] && continue
line 7 ($BASH_SOMETHING): if [ -n "$BASH_VERSION" ]; then
line 37 (read with option other than -r): read -p "WARNING: Currently in context $(kubectl config current-context). Continue? (y/N) " yn
It is very unlikely that on a Linux system /bin/sh will not be bash :-), and some of the constructs (especially "${0##*/}" = "bash" -a "$_" = "$0") look like they were written by someone who knew what he was doing, but if someone wants to climb down the rabbit hole of shell compatibility (or just replace #!/bin/sh with #!/bin/bash), you're welcome :-).