diff --git a/src/wifi-menu b/src/wifi-menu index 42c4c53..928cf5e 100755 --- a/src/wifi-menu +++ b/src/wifi-menu @@ -29,34 +29,22 @@ quote_safe() { fi } -# Fill PROFILES and ESSIDS with the profile names and essids of the profiles -# for interface $1 +# Fill GENERATED, PROFILES and ESSIDS with the profile names and essids of the +# profiles for interface $1 init_profiles() { - local i=0 essid profile + local i=0 profile while IFS= read -r profile; do - essid=$( - unset Interface ESSID - source "$PROFILE_DIR/$profile" > /dev/null - if [[ "$Interface" = "$1" && -n "$ESSID" ]]; then - printf "%s" "$ESSID" - if [[ "$Description" =~ "Automatically generated" ]]; then - return 2 - else - return 1 - fi - fi - return 0 - ) - case $? in - 2) - GENERATED+=("$profile") - ;& - 1) - PROFILES[i]=$profile - ESSIDS[i]=$essid - (( ++i )) - ;; - esac + unset Interface ESSID + source "$PROFILE_DIR/$profile" > /dev/null + if [[ "$Interface" != "$1" || -z "$ESSID" ]]; then + continue; + fi + if [[ "$Description" =~ "Automatically generated" ]]; then + GENERATED+=("$profile") + fi + PROFILES[i]=$profile + ESSIDS[i]=$ESSID + (( ++i )) done < <(list_profiles) }