Skip to content

Commit

Permalink
Fix issue with run_command and set -e in acceptance/lib.sh (#2135)
Browse files Browse the repository at this point in the history
  • Loading branch information
kormat authored Nov 16, 2018
1 parent 0fc1dc5 commit c2cd5b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions acceptance/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ run_command() {
local cmd="$1"
local out="$2"

# Save the state of errexit
[[ $- =~ e ]] && local e_set=y
# Unset errexit, so that $cmd failing won't quit the script.
set +e

# Run cmd, save return value.
$cmd &>> "${out:-/dev/stdout}"
local ret=$?

# Re-set errexit if it was previously set.
[ -n "$e_set" ] && set -e

if [[ -n "$out" && $ret -ne 0 ]]; then
cat "$out"
fi
Expand Down

0 comments on commit c2cd5b6

Please sign in to comment.