Skip to content

Commit

Permalink
remove unnecessary $? in return and exit calls
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Feb 2, 2025
1 parent 76b5565 commit 3f47d47
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion commands/eval-capture
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if [[ $* == '--test' ]]; then
)"
eval-tester --name='as expected' --status='1' --stdout="$expected" \
-- eval-capture --
exit $?
exit
elif [[ $* == '--' ]]; then
: # all good, run
else
Expand Down
2 changes: 1 addition & 1 deletion commands/is-dns-working
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function is_dns_working() (
echo-style --error1='DNS is not working.'
)" \
-- "${cmd[@]}"
return $?
return
)

# fire if invoked standalone
Expand Down
2 changes: 1 addition & 1 deletion commands/is-internet-working
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function is_internet_working() (
echo-style --error1='Internet is not working. If it is a DNS issue, then ' --code-error1='setup-dns' --error1=' may help.'
)" \
-- "${cmd[@]}"
return $?
return
)

# fire if invoked standalone
Expand Down
6 changes: 3 additions & 3 deletions commands/setup-dns
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ function setup_dns() (
# check
if ! __adguard_home__available; then
die_incompatible_dns_service "$adguard_home__title"
return $?
return
fi

# log
Expand Down Expand Up @@ -826,7 +826,7 @@ function setup_dns() (
# check
if ! __cloudflared__available; then
die_incompatible_dns_service "$cloudflared__title"
return $?
return
fi

# log
Expand Down Expand Up @@ -1069,7 +1069,7 @@ EOF
# check
if ! __dnscrypt_proxy__available; then
die_incompatible_dns_service "$dnscrypt_proxy__title"
return $?
return
fi

# prepare and log
Expand Down
2 changes: 1 addition & 1 deletion commands/setup-environment-commands
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export shell="${1-}"
# testing
if [[ $* == *'--refresh'* ]]; then
env -i DOROTHY="$DOROTHY" "$DOROTHY/commands/setup-environment-commands" "$shell"
exit $?
exit
fi

# environment provides:
Expand Down
2 changes: 1 addition & 1 deletion commands/setup-util-adguard-home
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
function setup_util_adguard_home() (
source "$DOROTHY/sources/bash.bash"
setup-dns --service='adguard-home' "$@"
return $?
return
)

# fire if invoked standalone
Expand Down
2 changes: 1 addition & 1 deletion commands/setup-util-cloudflared
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
function setup_util_cloudflared() (
source "$DOROTHY/sources/bash.bash"
setup-dns --service='cloudflared' "$@"
return $?
return
)

# fire if invoked standalone
Expand Down
2 changes: 1 addition & 1 deletion commands/setup-util-dnscrypt-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
function setup_util_dnscrypt_proxy() (
source "$DOROTHY/sources/bash.bash"
setup-dns --service='dnscrypt-proxy' "$@"
return $?
return
)

# fire if invoked standalone
Expand Down
2 changes: 1 addition & 1 deletion sources/bash.bash
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ function eval_capture {
# __print_lines "PRE: [$EVAL_CAPTURE_STATUS] cmd=[$EVAL_CAPTURE_COMMAND] subshell=[$EVAL_CAPTURE_SUBSHELL] context=[$EVAL_CAPTURE_CONTEXT]" >/dev/tty
EVAL_CAPTURE_COUNT="$((EVAL_CAPTURE_COUNT + 1))"
# wrap if the $- check, as always returning causes +e to return when it shouldn't
trap 'EVAL_CAPTURE_RETURN=$?; if [[ $- = *e* ]]; then eval_capture_wrapper_trap "$EVAL_CAPTURE_RETURN" "${FUNCNAME-}" "${cmd[*]}" "${BASH_SUBSHELL-}" "$EVAL_CAPTURE_CONTEXT"; return $?; fi' ERR
trap 'EVAL_CAPTURE_RETURN=$?; if [[ $- = *e* ]]; then eval_capture_wrapper_trap "$EVAL_CAPTURE_RETURN" "${FUNCNAME-}" "${cmd[*]}" "${BASH_SUBSHELL-}" "$EVAL_CAPTURE_CONTEXT"; return; fi' ERR
# can't delegate this to a function (e.g. is_subshell_function), as the trap will go to the function
if [[ $IS_BASH_VERSION_OUTDATED == 'yes' && $- == *e* && "$(declare -f "${cmd[0]}")" == "${cmd[0]}"$' () \n{ \n ('* ]]; then
# ALL SUBSHELLS SHOULD RE-ENABLE [set -e]
Expand Down

0 comments on commit 3f47d47

Please sign in to comment.