Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with run_command and set -e in acceptance/lib.sh #2135

Merged
merged 1 commit into from
Nov 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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