In the ALCI installation, the Arch-updates Polybar module does not display updates, though it responds to click open. So I started looking into this.
Because scripting and I will never get along, I ran it through shellcheck, which found and easily provided the following correction:
Code: Select all
$ shellcheck myscript
Line 9:
if [ $updates_arch -gt 0 ]; then
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: (apply this, apply all SC2086)
if [ "$updates_arch" -gt 0 ]; then
Line 10:
echo $updates_arch
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: (apply this, apply all SC2086)
echo "$updates_arch"
Code: Select all
#!/bin/sh
#source https://github.com/x70b1/polybar-scripts
#source https://github.com/polybar/polybar-scripts
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
updates_arch=0
fi
if [ $updates_arch -gt 0 ]; then
echo $updates_arch
else
echo "0"
fi
However, when I try this trick with tempcores, I get the following:
Code: Select all
$ shellcheck myscript
Line 8:
tempCore=($rawData)
^-- SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
Line 29:
sum=$(( $total/${#tempCore[*]} ))
^-- SC2004 (style): $/${} is unnecessary on arithmetic variables.
Line 43:
echo $finalEcho
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean: (apply this, apply all SC2086)
echo "$finalEcho"
Code: Select all
$ shellcheck myscript
Line 8:
tempCore=($rawData)
^-- SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
Line 29:
sum=$(( $total/${#tempCore[*]} ))
^-- SC2004 (style): $/${} is unnecessary on arithmetic variables.
For your consideration.