Verified Commit 8bb3e8c1 authored by David Runge's avatar David Runge
Browse files

Fix linter errors in livecd-sound

configs/releng/airootfs/usr/local/bin/livecd-sound:
Replace oldstyle expr with a bash test in `is_numeric()`.

Replace use of `nword()` with call to `wc -w`.

Quote variables in `pick_a_card()`.

Fixes #78
parent 6a39300b
...@@ -136,7 +136,7 @@ sanify_levels_on_card() ...@@ -136,7 +136,7 @@ sanify_levels_on_card()
# $1 <card ID> | "all" # $1 <card ID> | "all"
sanify_levels() sanify_levels()
{ {
local ttsdml_returnstatus=0 local ttsdml_returnstatus=0
local card local card
case "$1" in case "$1" in
all) all)
...@@ -171,13 +171,9 @@ unmute_all_cards() ...@@ -171,13 +171,9 @@ unmute_all_cards()
sanify_levels all sanify_levels all
} }
nwords() {
echo $#
}
is_numeric() { is_numeric() {
local str=$1 local str=$1
expr match "$str" '[[:digit:]]\+$' > /dev/null 2>&1 [[ "$str" =~ ^[0-9]+$ ]]
} }
set_default_card() { set_default_card() {
...@@ -197,7 +193,7 @@ pick_a_card() ...@@ -197,7 +193,7 @@ pick_a_card()
{ {
set -f set -f
usable_cards="$(list_non_pcsp_cards)" usable_cards="$(list_non_pcsp_cards)"
num_usable_cards=$(nwords $usable_cards) num_usable_cards="$(wc -w <<< "$usable_cards")"
if [ "$num_usable_cards" -eq 1 ]; then if [ "$num_usable_cards" -eq 1 ]; then
systemd-cat -t "livecdsound" printf "Only one sound card is detected\n" systemd-cat -t "livecdsound" printf "Only one sound card is detected\n"
......
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