refactor: set pipefail conditionally
expand alias in bash
This commit is contained in:
parent
edadc7a596
commit
e84f2e0c7b
|
@ -1,14 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
## 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
|
||||
if ! (set -o pipefail 2>/dev/null); then
|
||||
# dash does not support pipefail
|
||||
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
|
||||
|
||||
alias curl="curl -L"
|
||||
alias mkdir="mkdir -p"
|
||||
alias rm="rm -rf"
|
||||
|
|
Loading…
Reference in New Issue