[bin/qrwifi] Take only first password

This commit is contained in:
Midgard 2023-07-26 18:12:57 +02:00
parent 652d261ee9
commit f622651482
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -11,7 +11,7 @@ fi
pw="${2:-}"
if [ -z "$pw" ]; then
pw="$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf | sed -n '/^[\t ]*ssid="'"$ssid"'"$/{:findpsk;N;/}/d;/\n[\t ]*psk=/!b findpsk;s/^\(\n\|.\)*[\t ]*psk="\(.*\)"$/\2/p; }')"
pw="$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf | sed -n '/^[\t ]*ssid="'"$ssid"'"$/{:findpsk;N;/}/d;/\n[\t ]*psk=/!b findpsk;s/^\(\n\|.\)*[\t ]*psk="\([^"]*\)"$/\2/p; t quit}; d; :quit; q')"
fi
if [ -z "$pw" ]; then
echo "Couldn't find password for network \`$ssid\`"