Skip to content

Commit

Permalink
src/winusb: Defensive Bash Programming: use named variable to catch f…
Browse files Browse the repository at this point in the history
…unction arguments

Signed-off-by: 林博仁 <[email protected]>
  • Loading branch information
brlin-tw committed Jun 7, 2017
1 parent d8b62cc commit 4d906a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/winusb
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,15 @@ trap_debug(){
## An utility function for inhibiting command call output and
## only show them to user when error occurred
util_call_external_command(){
local -r command="${@}"

set +o errexit
TEXT="$( "$@" 2>&1 )"
TEXT="$( "${command}" 2>&1 )"
RETURN="$?"
set -o errexit

if [ "$RETURN" -ne 0 ]; then
echo_with_color red "Error while running command '$*' (exit code : $RETURN)!" >&2
echo_with_color red "Error while running command '${command}' (exit code : $RETURN)!" >&2
echo_with_color red "Read command output (Y/n)?" >&2

rep='y'
Expand Down

0 comments on commit 4d906a4

Please sign in to comment.