Skip to content

Commit

Permalink
print raw $BASH_COMMAND on error
Browse files Browse the repository at this point in the history
in case of error, BASH_COMMAND contains
the command that throw the error (catched by
the trap).
As the command is with variables (as example:
$TORBIN" -f "$TORCONFIGFILE"), I was evaluating
it to show the real command to the user.
this is not always possible because if the command
contains a &> /dev/null this will be evaluated to
showing an empty string to user.
This restore the raw command plus a message if -v
flag was not specified.
  • Loading branch information
lesion committed Sep 18, 2018
1 parent 2919180 commit 00961d5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions usr/sbin/orjail
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ eno() {
# kill tor, remove network namespace, cleanup added iptables rules
cleanup() {
if [ "$NOSETUPERROR" != y ]; then
ERROR_COMMAND=$(eval echo "${BASH_COMMAND//\"/\\\"}")
printv R "[Error] $ERROR_COMMAND"
printv R "[Error] in command: $BASH_COMMAND"
if [ "$VERBOSE" != y ]; then
printv R "[Error] Enable verbose mode to debug (using -v)"
fi
fi
set +e

Expand Down Expand Up @@ -516,7 +518,11 @@ EOF

# executing tor
print G " * Executing Tor..."
eno "$TORBIN" -f "$TORCONFIGFILE"
if [ "$VERBOSE" != y ]; then
"$TORBIN" -f "$TORCONFIGFILE" &>/dev/null
else
"$TORBIN" -f "$TORCONFIGFILE"
fi
else
print Y "$NAME network namespace already exists!"
fi
Expand Down

0 comments on commit 00961d5

Please sign in to comment.