mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-22 04:45:11 +00:00
Use if..then
in show
to avoid non-zero exits.
The `[[ ... ]] && ...` conditional style results in non-zero exits when the test is false. Moving this to a traditional `if..then` style avoids this behavior while also being more explicit about the objective of the code. `|| return 0` or `|| exit 0` could have been added as an alternative way to avoid the non-zero exit behavior, but is not used in this case because the traditional `if..then` style is more common.
This commit is contained in:
parent
4d1adbdf52
commit
80a8e48c10
10
hosts
10
hosts
@ -1084,8 +1084,14 @@ show() {
|
||||
grep "^[^#]*$1" "${HOSTS_PATH}"
|
||||
)
|
||||
# Output disabled records secondly for better organization.
|
||||
[[ -n "$enabled_records" ]] && printf "%s\n" "$enabled_records"
|
||||
[[ -n "$disabled_records" ]] && printf "%s\n" "$disabled_records"
|
||||
if [[ -n "$enabled_records" ]]
|
||||
then
|
||||
printf "%s\n" "$enabled_records"
|
||||
fi
|
||||
if [[ -n "$disabled_records" ]]
|
||||
then
|
||||
printf "%s\n" "$disabled_records"
|
||||
fi
|
||||
else
|
||||
$_ME help show
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user