From e6c003bdecb7dd79458ff27702b35a3010423040 Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Mon, 3 Jun 2024 08:24:44 +0000 Subject: [PATCH] fix: expand alias in bash --- src/script.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/script.sh b/src/script.sh index 3d23d02..3f12b56 100644 --- a/src/script.sh +++ b/src/script.sh @@ -1,14 +1,18 @@ #!/bin/sh -## dash does not support pipefail +# dash does not support pipefail # this does not work in `dash script.sh` -DASH=$(readlink -f "/bin/sh" | grep "dash" || [ $? = 1 ]) -if [ -n "$DASH" ]; then +IS_DASH=$(readlink -f "/bin/sh" | grep "dash" || [ $? = 1 ]) +if [ -n "$IS_DASH" ]; then set -efx else set -efx -o pipefail fi +# bash does not expand alias by default for non-interactive script +if [ -n "$BASH_VERSION" ]; then + shopt -s expand_aliases +fi ## Use GNU grep, busybox grep is not as performant DISTRO=""