refactor: set pipefail conditionally

This commit is contained in:
Ming Di Leom 2024-07-15 08:01:33 +00:00
parent a15c6988e2
commit 9261c22de3
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
1 changed files with 2 additions and 4 deletions

View File

@ -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