Skip to content

Commit 74205c7

Browse files
committed
Polyglot works when dash is invoked as sh
1 parent e1eede9 commit 74205c7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

polyglot.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,16 @@ _polyglot_is_dtksh() {
360360
esac
361361
}
362362

363+
###########################################################
364+
# Test to see if sh is really dash
365+
###########################################################
366+
_polyglot_sh_is_dash() {
367+
case $(ls -l "$(command -v "$0")") in
368+
*dash*) return 0 ;;
369+
*) return 1 ;;
370+
esac
371+
}
372+
363373
#####################################################################
364374
# zsh
365375
#####################################################################
@@ -614,7 +624,8 @@ elif [ "$KSH_VERSION" ] || _polyglot_is_dtksh || [ "$ZSH_VERSION" ] \
614624
# pdksh, dash, busybox ash, and zsh in sh emulation mode
615625
####################################################################
616626

617-
elif _polyglot_is_pdksh || [ "$0" = 'dash' ] || _polyglot_is_busybox; then
627+
elif _polyglot_is_pdksh || [ "$0" = 'dash' ] || _polyglot_is_busybox \
628+
|| _polyglot_sh_is_dash; then
618629

619630
# Only display the $HOSTNAME for an ssh connection
620631
if _polyglot_is_ssh || _polyglot_is_superuser; then
@@ -695,6 +706,6 @@ fi
695706

696707
# Clean up environment
697708
unset -f _polyglot_is_ssh _polyglot_basename _polyglot_is_busybox \
698-
_polyglot_is_dtksh _polyglot_is_pdksh
709+
_polyglot_is_dtksh _polyglot_is_pdksh _polyglot_sh_is_dash
699710

700711
# vim: ts=2:et:sts=2:sw=2

0 commit comments

Comments
 (0)