From a76fb2cd523528fb4a8215bdec8cc9484a0e75d2 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Wed, 27 Jan 2021 20:45:00 +0300 Subject: [PATCH] Pull request: scrips: make go-lint show output even when command fails Merge in DNS/adguard-home from imp-go-lint to master Squashed commit of the following: commit 4ac92d95071b747e01e30713030e72396f1c353f Author: Ainar Garipov Date: Wed Jan 27 20:35:35 2021 +0300 scrips: make go-lint show output even when command fails --- scripts/make/go-lint.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/scripts/make/go-lint.sh b/scripts/make/go-lint.sh index 417b6b57..391e8c51 100644 --- a/scripts/make/go-lint.sh +++ b/scripts/make/go-lint.sh @@ -60,14 +60,24 @@ underscores() { # exit_on_output exits with a nonzero exit code if there is anything in # the command's combined output. -exit_on_output() { - test "$VERBOSE" -lt '2' && set +x +exit_on_output() ( + set +e + + if [ "$VERBOSE" -lt '2' ] + then + set +x + fi cmd="$1" shift - exitcode='0' output="$("$cmd" "$@" 2>&1)" + exitcode="$?" + if [ "$exitcode" != '0' ] + then + echo "'$cmd' failed with code $exitcode" + fi + if [ "$output" != '' ] then if [ "$*" != '' ] @@ -79,13 +89,14 @@ exit_on_output() { echo "$output" - exitcode='1' + if [ "$exitcode" = '0' ] + then + exitcode='1' + fi fi - test "$VERBOSE" -gt '0' && set -x - return "$exitcode" -} +) exit_on_output blocklist_imports