shell-scripts: Use [[ instead of [ where possible

Replace all occurrences of [ with [[ in bash and zsh scripts and
configs.
Performance wise it makes sense to use the builtin instead of calling an
external command also when from a functionality stand point `test` would
suffice.
This commit is contained in:
2020-10-03 01:29:29 +02:00
parent 29d28a25ee
commit 4cb445c2b5
14 changed files with 64 additions and 64 deletions

View File

@@ -17,13 +17,13 @@ declare -a ramp
ramp=(          )
# display in red when under $low and no charger is connected
[ "$bat" -gt "$low" ] || [ "$ac" -eq 1 ] || color="$red"
[[ "$bat" -gt "$low" || "$ac" -eq 1 ]] || color="$red"
# display in green when over $full and a charger is connected
[ "$bat" -lt "$full" ] || [ "$ac" -eq 0 ] || color="$green"
[[ "$bat" -lt "$full" || "$ac" -eq 0 ]] || color="$green"
let "icon_index = $bat / (${#ramp[@]} - 1)"
[ $icon_index -lt ${#ramp[@]} ] || icond_index=10
[[ $icon_index -lt ${#ramp[@]} ]] || icond_index=10
icon="${ramp[$icon_index]}"
[ "$ac" -eq 0 ] || charge=""
[[ "$ac" -eq 0 ]] || charge=""
echo "${color}${icon}${charge} ${bat}%"