From 131bcdae108e804aba89092faaa2e3fb7938aa88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Carvalho?= Date: Wed, 27 May 2020 15:24:30 -0300 Subject: [PATCH 1/2] Improve wireless detection when interface is down --- scripts/network.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/network.sh b/scripts/network.sh index 045445c..fdfda04 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -7,8 +7,9 @@ get_ssid() # Check OS case $(uname -s) in Linux) - if iw dev | grep ssid | cut -d ' ' -f 2 &> /dev/null; then - echo "$(iw dev | grep ssid | cut -d ' ' -f 2)" + SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p') + if [ -n "$SSID" ]; then + echo -- "$SSID" else echo 'Ethernet' fi From ec2739e9ba83ef4deedf9312994a62190cf301cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Carvalho?= Date: Wed, 27 May 2020 15:37:26 -0300 Subject: [PATCH 2/2] Use of "printf" command to avoid shell interpretation of dashes ("-") or percent sign ("%") --- scripts/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/network.sh b/scripts/network.sh index fdfda04..6ec84ad 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -9,7 +9,7 @@ get_ssid() Linux) SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p') if [ -n "$SSID" ]; then - echo -- "$SSID" + printf '%s' "$SSID" else echo 'Ethernet' fi