From 8b024af84e7bf49d499cff47c1c75d2318276c02 Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Mon, 15 Jul 2024 08:03:17 +0000 Subject: [PATCH] refactor: set pipefail conditionally --- src/script.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/script.sh b/src/script.sh index 6181713..502da65 100644 --- a/src/script.sh +++ b/src/script.sh @@ -1,9 +1,7 @@ #!/bin/sh -# dash does not support pipefail -# this does not work in `dash script.sh` -IS_DASH=$(readlink -f "/bin/sh" | grep "dash" || [ $? = 1 ]) -if [ -n "$IS_DASH" ]; then +if ! (set -o pipefail 2>/dev/null); then + # dash does not support pipefail set -efx else set -efx -o pipefail @@ -14,7 +12,6 @@ if [ -n "$BASH_VERSION" ]; then shopt -s expand_aliases fi - ## Use GNU grep, busybox grep is not as performant DISTRO="" if [ -f "/etc/os-release" ]; then