From 9e1686fd996a817e565987d55d832ccbafac6c38 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 30 Dec 2019 23:03:21 +0100 Subject: [PATCH] Prevent globbing and word splitting --- .scripts/panel/battery.sh | 6 +++--- .scripts/panel/wifi.sh | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.scripts/panel/battery.sh b/.scripts/panel/battery.sh index fac0236..60ae2c7 100755 --- a/.scripts/panel/battery.sh +++ b/.scripts/panel/battery.sh @@ -2,8 +2,8 @@ BAT_INFO=${BLOCK_INSTANCE:-"$(acpi -b | grep ': [^Unknown]')"} -CAPACITY=$(echo $BAT_INFO | awk '{ print int($4) }') -TIME="$(echo $BAT_INFO | awk '{ print substr($5, 0, length($5) - 3) }')" +CAPACITY=$(echo "$BAT_INFO" | awk '{ print int($4) }') +TIME="$(echo "$BAT_INFO" | awk '{ print substr($5, 0, length($5) - 3) }')" CHARACTER=":" if [ "$TIME" != "" ] && [ "${TIME#*$CHARACTER}" != "$TIME" ]; then @@ -13,7 +13,7 @@ else fi COLOR="-" -if [ "$(echo $BAT_INFO | awk '{ print $6 }')" = "remaining" ]; then +if [ "$(echo "$BAT_INFO" | awk '{ print $6 }')" = "remaining" ]; then if [ "$CAPACITY" -ge "80" ]; then ICON="" elif [ "$CAPACITY" -ge "60" ]; then diff --git a/.scripts/panel/wifi.sh b/.scripts/panel/wifi.sh index a87b721..3408a4d 100755 --- a/.scripts/panel/wifi.sh +++ b/.scripts/panel/wifi.sh @@ -4,8 +4,8 @@ ICON="" WIRELESS="${1:-wlan0}" if [ "$NOTIFY" = "1" ]; then - SSID="$(iw dev $WIRELESS link | awk '/SSID/ { print $2 }')" - IP="$(ip a show $WIRELESS \ + SSID="$(iw dev "$WIRELESS" link | awk '/SSID/ { print $2 }')" + IP="$(ip a show "$WIRELESS" \ | awk '/inet / { print substr($2, 0, length($2) - 3) }')" notify-send -r 3 "Wifi" "\ @@ -14,13 +14,13 @@ SSID: $SSID IP: $IP" else COLOR="-" - if [ ! -d /sys/class/net/${WIRELESS}/wireless ] || - [ "$(cat /sys/class/net/$WIRELESS/operstate)" = 'down' ]; then + if [ ! -d /sys/class/net/"$WIRELESS"/wireless ] || + [ "$(cat /sys/class/net/"$WIRELESS"/operstate)" = 'down' ]; then COLOR="$COLOR7" DISPLAY="$ICON" else - QUALITY=$(grep $WIRELESS /proc/net/wireless | \ + QUALITY=$(grep "$WIRELESS" /proc/net/wireless | \ awk '{ print int($3 * 100 / 70) }') COLOR="$COLOR15"