Commit 17cbd88d authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Use if statements for non-problematic checks

The shorthand && or || sets the return value to 1 when they fail, which
can then become the return value of a function.

Observed and reported by David Dorfman.
parent d93ef2aa
......@@ -64,8 +64,9 @@ restore() {
stop_all() {
# We cannot pipe to mapfile, as the end of a pipe is inside a subshell
mapfile -t Profiles < <(list_profiles)
(( ${#Profiles[@]} )) && do_debug sd_call stop "${Profiles[@]}" 2> \
>(grep -Fv "not loaded" >&2)
if (( ${#Profiles[@]} )); then
do_debug sd_call stop "${Profiles[@]}" 2> >(grep -Fv "not loaded" >&2)
fi
}
switch_to() {
......@@ -82,8 +83,9 @@ switch_to() {
fi
mapfile -t AllProfiles < <(list_profiles)
mapfile -t Profiles < <(grep -Fl "$InterfaceLine" "${AllProfiles[@]}")
(( ${#Profiles[@]} )) && do_debug sd_call stop "${Profiles[@]}" 2> \
>(grep -Fv "not loaded" >&2)
if (( ${#Profiles[@]} )); then
do_debug sd_call stop "${Profiles[@]}" 2> >(grep -Fv "not loaded" >&2)
fi
do_debug sd_call start "$1"
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment