refactor: set pipefail conditionally
This commit is contained in:
parent
d80cd36062
commit
8b024af84e
|
@ -1,9 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# dash does not support pipefail
|
if ! (set -o pipefail 2>/dev/null); then
|
||||||
# this does not work in `dash script.sh`
|
# dash does not support pipefail
|
||||||
IS_DASH=$(readlink -f "/bin/sh" | grep "dash" || [ $? = 1 ])
|
|
||||||
if [ -n "$IS_DASH" ]; then
|
|
||||||
set -efx
|
set -efx
|
||||||
else
|
else
|
||||||
set -efx -o pipefail
|
set -efx -o pipefail
|
||||||
|
@ -14,7 +12,6 @@ if [ -n "$BASH_VERSION" ]; then
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Use GNU grep, busybox grep is not as performant
|
## Use GNU grep, busybox grep is not as performant
|
||||||
DISTRO=""
|
DISTRO=""
|
||||||
if [ -f "/etc/os-release" ]; then
|
if [ -f "/etc/os-release" ]; then
|
||||||
|
|
Loading…
Reference in New Issue