Commit 98e0da58 authored by Ivan Pozdeev's avatar Ivan Pozdeev Committed by Matthew Brett
Browse files

Allow spaces in suppress() args

parent e0049424
......@@ -117,13 +117,14 @@ function suppress {
# Set -e stuff agonized over in
# https://unix.stackexchange.com/questions/296526/set-e-in-a-subshell
local tmp=$(mktemp tmp.XXXXXXXXX) || return
local opts=$-
local ERREXIT_SET OUT
echo "Running $@"
if [[ $- = *e* ]]; then ERREXIT_SET=true; fi
set +e
( set_opts $opts ; $@ > "$tmp" 2>&1 ) ; ret=$?
( if [[ -n $ERREXIT_SET ]]; then set -e; fi; "$@" > "$tmp" 2>&1 ) ; ret=$?
[ "$ret" -eq 0 ] || cat "$tmp"
rm -f "$tmp"
set_opts $opts
if [[ -n $ERREXIT_SET ]]; then set -e; fi
return "$ret"
}
......
......@@ -69,6 +69,8 @@ ORIG_OPTS=$-
set +ex
[ "$(suppress bad_cmd)" == "$(printf "Running bad_cmd\nbad")" ] \
|| ingest "suppress bad_cmd"
suppress bash -c '! false' &>/dev/null \
|| ingest "suppress cmd with space"
[ "$(suppress good_cmd)" == "Running good_cmd" ] \
|| ingest "suppress good_cmd"
[ "$(suppress bad_mid_cmd)" == "Running bad_mid_cmd" ] \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment