Skip to content

Commit

Permalink
ffac-ssid-changer: use globs instead of ls output
Browse files Browse the repository at this point in the history
Fixes shellcheck SC2045:
Iterating over ls output is fragile. Use globs.
  • Loading branch information
grische authored and maurerle committed Nov 19, 2023
1 parent 2fd3b17 commit 5f98ca2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ffac-ssid-changer/shsrc/ssid-changer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
echo "node is online"
LOOP=1
# check status for all physical devices
for HOSTAPD in $(ls /var/run/hostapd-phy*); do
for HOSTAPD in /var/run/hostapd-phy*; do
[ -e "$HOSTAPD" ] || break # handle the case of no hostapd-phy* files
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
LOOP=$((LOOP+1))
CURRENT_SSID="$(grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
Expand Down Expand Up @@ -165,7 +166,8 @@ elif [ "$CHECK" -eq 0 ]; then
if [ $OFF_COUNT -ge $(($T / 2)) ]; then
# node was offline more times than half of switch_timeframe (or than $FIRST)
LOOP=1
for HOSTAPD in $(ls /var/run/hostapd-phy*); do
for HOSTAPD in /var/run/hostapd-phy*; do
[ -e "$HOSTAPD" ] || break # handle the case of no hostapd-phy* files
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
LOOP=$((LOOP+1))
CURRENT_SSID="$(grep "^ssid=$OFFLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
Expand Down

0 comments on commit 5f98ca2

Please sign in to comment.