Skip to content

Commit

Permalink
airmon-ng.linux: in a for loop, replace ls with a glob
Browse files Browse the repository at this point in the history
xtrace comparison:

# original
[root@localhost-live bug_airmon-ng-email]# set -x; for i in $(ls /sys/class/ieee80211/); do if [ ! -d "/sys/class/ieee80211/${i}/device/net" ]; then echo "$MISSING_INTERFACE" :: "$i"; fi; done; set -
++ ls --color=auto /sys/class/ieee80211/
+ for i in $(ls /sys/class/ieee80211/)
+ '[' '!' -d /sys/class/ieee80211/phy0/device/net ']'
+ set -

# change added
[root@localhost-live bug_airmon-ng-email]# set -x; for i in /sys/class/ieee80211/*; do if [ -e "${i}" ] && [ ! -d "${i}/device/net" ]; then MISSING_INTERFACE="${i}"; echo "$MISSING_INTERFACE" :: "$i"; fi; done; set -
+ for i in /sys/class/ieee80211/*
+ '[' -e /sys/class/ieee80211/phy0 ']'
+ '[' '!' -d /sys/class/ieee80211/phy0/device/net ']'
+ set -
  • Loading branch information
wileyhy committed Jul 10, 2023
1 parent d4e7705 commit e833818
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/airmon-ng.linux
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ handleLostPhys() {
if [ -d /sys/class/ieee80211 ]; then
#this should be fixed, but it's not going to be right now
# shellcheck disable=2045
for i in $(ls /sys/class/ieee80211/); do
if [ ! -d "/sys/class/ieee80211/${i}/device/net" ]; then
for i in /sys/class/ieee80211/*; do
if [ -e "${i}" ] && [ ! -d "${i}/device/net" ]; then
MISSING_INTERFACE="${i}"
printf "\nFound %s with no interfaces assigned, would you like to assign one to it? [y/n] " "${MISSING_INTERFACE}"
yesorno
Expand Down

0 comments on commit e833818

Please sign in to comment.