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 <A.Garipov@AdGuard.COM>
Date:   Wed Jan 27 20:35:35 2021 +0300

    scrips: make go-lint show output even when command fails
This commit is contained in:
Ainar Garipov 2021-01-27 20:45:00 +03:00
parent fc9ddcf941
commit a76fb2cd52
1 changed files with 18 additions and 7 deletions

View File

@ -60,14 +60,24 @@ underscores() {
# exit_on_output exits with a nonzero exit code if there is anything in # exit_on_output exits with a nonzero exit code if there is anything in
# the command's combined output. # the command's combined output.
exit_on_output() { exit_on_output() (
test "$VERBOSE" -lt '2' && set +x set +e
if [ "$VERBOSE" -lt '2' ]
then
set +x
fi
cmd="$1" cmd="$1"
shift shift
exitcode='0'
output="$("$cmd" "$@" 2>&1)" output="$("$cmd" "$@" 2>&1)"
exitcode="$?"
if [ "$exitcode" != '0' ]
then
echo "'$cmd' failed with code $exitcode"
fi
if [ "$output" != '' ] if [ "$output" != '' ]
then then
if [ "$*" != '' ] if [ "$*" != '' ]
@ -79,13 +89,14 @@ exit_on_output() {
echo "$output" echo "$output"
if [ "$exitcode" = '0' ]
then
exitcode='1' exitcode='1'
fi fi
fi
test "$VERBOSE" -gt '0' && set -x
return "$exitcode" return "$exitcode"
} )
exit_on_output blocklist_imports exit_on_output blocklist_imports