Misc: Quote unquoted vars

This commit is contained in:
Dylan Araps 2016-11-06 21:21:23 +11:00
parent e94a57c8c4
commit 6b0a9ebf94
1 changed files with 24 additions and 24 deletions

View File

@ -170,9 +170,9 @@ getdistro() {
done done
case "$distro_shorthand" in case "$distro_shorthand" in
"on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;; "on") distro="${NAME:-"${DISTRIB_ID}"} ${VERSION_ID:-"${DISTRIB_RELEASE}"}" ;;
"tiny") distro="${NAME:-${DISTRIB_ID:-"${TAILS_PRODUCT_NAME}"}}" ;; "tiny") distro="${NAME:-"${DISTRIB_ID:-"${TAILS_PRODUCT_NAME}"}"}" ;;
"off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;; "off") distro="${PRETTY_NAME:-"${DISTRIB_DESCRIPTION}"} ${UBUNTU_CODENAME}" ;;
esac esac
# Workarounds for distros that go against the os-release standard. # Workarounds for distros that go against the os-release standard.
@ -202,14 +202,14 @@ getdistro() {
distro="$codename $osx_version $osx_build" distro="$codename $osx_version $osx_build"
case "$distro_shorthand" in case "$distro_shorthand" in
"on") distro="${distro/ ${osx_build}}" ;; "on") distro="${distro/ "${osx_build}"}" ;;
"tiny") "tiny")
case "$osx_version" in case "$osx_version" in
"10."[4-7]*) distro="${distro/${codename}/Mac OS X}" ;; "10."[4-7]*) distro="${distro/${codename}/Mac OS X}" ;;
"10."[8-9]* | "10.1"[0-1]*) distro="${distro/${codename}/OS X}" ;; "10."[8-9]* | "10.1"[0-1]*) distro="${distro/${codename}/OS X}" ;;
"10.12"*) distro="${distro/${codename}/macOS}" ;; "10.12"*) distro="${distro/${codename}/macOS}" ;;
esac esac
distro="${distro/ ${osx_build}}" distro="${distro/ "${osx_build}"}"
;; ;;
esac esac
;; ;;
@ -435,13 +435,13 @@ getpackages() {
packages="$(($(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) - 1))" packages="$(($(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) - 1))"
type -p port >/dev/null && \ type -p port >/dev/null && \
packages="$((packages + $(port installed | wc -l) - 1))" packages="$((packages + "$(port installed | wc -l)" - 1))"
type -p brew >/dev/null && \ type -p brew >/dev/null && \
packages="$((packages + $(find /usr/local/Cellar -maxdepth 1 | wc -l) - 1))" packages="$((packages + "$(find /usr/local/Cellar -maxdepth 1 | wc -l)" - 1))"
type -p pkgin >/dev/null && \ type -p pkgin >/dev/null && \
packages="$((packages + $(pkgin list | wc -l)))" packages="$((packages + "$(pkgin list | wc -l)"))"
;; ;;
"BSD") "BSD")
@ -692,7 +692,7 @@ getwmtheme() {
path="$(wmic process get ExecutablePath | grep -F "blackbox")" path="$(wmic process get ExecutablePath | grep -F "blackbox")"
path="${path//'\'/'/'}" path="${path//'\'/'/'}"
wmtheme="$(grep "^session\.styleFile:" ${path/\.exe/.rc})" wmtheme="$(grep "^session\.styleFile:" "${path/\.exe/.rc}")"
wmtheme="${wmtheme/'session.styleFile: '}" wmtheme="${wmtheme/'session.styleFile: '}"
wmtheme="${wmtheme##*\\}" wmtheme="${wmtheme##*\\}"
wmtheme="${wmtheme%.*}" wmtheme="${wmtheme%.*}"
@ -926,9 +926,9 @@ getcpu_usage() {
# Print the bar # Print the bar
case "$cpu_display" in case "$cpu_display" in
"bar") cpu_usage="$(bar $cpu_usage 100)" ;; "bar") cpu_usage="$(bar "$cpu_usage" 100)" ;;
"infobar") cpu_usage="${cpu_usage}% $(bar $cpu_usage 100)" ;; "infobar") cpu_usage="${cpu_usage}% $(bar "$cpu_usage" 100)" ;;
"barinfo") cpu_usage="$(bar $cpu_usage 100) ${cpu_usage}%" ;; "barinfo") cpu_usage="$(bar "$cpu_usage" 100) ${cpu_usage}%" ;;
*) cpu_usage="${cpu_usage}%" ;; *) cpu_usage="${cpu_usage}%" ;;
esac esac
} }
@ -1412,7 +1412,7 @@ getstyle() {
gtk3theme="$(grep "^[^#]*$name" "$XDG_CONFIG_HOME/gtk-3.0/settings.ini")" gtk3theme="$(grep "^[^#]*$name" "$XDG_CONFIG_HOME/gtk-3.0/settings.ini")"
elif type -p gsettings >/dev/null; then elif type -p gsettings >/dev/null; then
gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)" gtk3theme="$(gsettings get org.gnome.desktop.interface "$gsettings")"
elif [ -f "/usr/share/gtk-3.0/settings.ini" ]; then elif [ -f "/usr/share/gtk-3.0/settings.ini" ]; then
gtk3theme="$(grep "^[^#]*$name" /usr/share/gtk-3.0/settings.ini)" gtk3theme="$(grep "^[^#]*$name" /usr/share/gtk-3.0/settings.ini)"
@ -1503,10 +1503,10 @@ getterm() {
;; ;;
"Windows") "Windows")
parent="$(ps -p ${1:-$PPID} | awk '{printf $2}')" parent="$(ps -p "${1:-$PPID}" | awk '{printf $2}')"
parent="${parent/'PPID'}" parent="${parent/'PPID'}"
name="$(ps -p $parent | awk '{printf $8}')" name="$(ps -p "$parent" | awk '{printf $8}')"
name="${name/'COMMAND'}" name="${name/'COMMAND'}"
name="${name/*\/}" name="${name/*\/}"
;; ;;
@ -1517,8 +1517,8 @@ getterm() {
;; ;;
*) *)
parent="$(ps -p ${1:-$PPID} -o ppid=)" parent="$(ps -p "${1:-$PPID}" -o ppid=)"
name="$(ps -p $parent -o comm=)" name="$(ps -p "$parent" -o comm=)"
;; ;;
esac esac
@ -1540,7 +1540,7 @@ gettermfont() {
case "$term" in case "$term" in
"urxvt" | "urxvtd" | "xterm") "urxvt" | "urxvtd" | "xterm")
termfont="$(grep -i -F "${term/d}*font" <<< $(xrdb -query))" termfont="$(grep -i -F "${term/d}*font" <<< "$(xrdb -query)")"
termfont="${termfont/*font: }" termfont="${termfont/*font: }"
# Xresources has two different font syntax, this checks which # Xresources has two different font syntax, this checks which
@ -1572,7 +1572,7 @@ gettermfont() {
;; ;;
"terminology") "terminology")
termfont="$(strings ${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg | awk '/^font\.name$/{print a}{a=$0}')" termfont="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" | awk '/^font\.name$/{print a}{a=$0}')"
termfont="${termfont/.pcf}" termfont="${termfont/.pcf}"
termfont="${termfont/:*}" termfont="${termfont/:*}"
;; ;;
@ -1661,8 +1661,8 @@ getbattery() {
# do multi battery support with a single battery per line. # do multi battery support with a single battery per line.
if [ -f /sys/class/power_supply/**/capacity ]; then if [ -f /sys/class/power_supply/**/capacity ]; then
for bat in "/sys/class/power_supply/BAT"*; do for bat in "/sys/class/power_supply/BAT"*; do
capacity="$(< ${bat}/capacity)" capacity="$(< "${bat}/capacity")"
status="$(< ${bat}/status)" status="$(< "${bat}/status")"
# Fix for bash on Windows 10 which includes /proc files # Fix for bash on Windows 10 which includes /proc files
# for battery usage despite there not being a battery # for battery usage despite there not being a battery
@ -1873,7 +1873,7 @@ getcols() {
block_width="${block_width// /█}" block_width="${block_width// /█}"
# Generate the string. # Generate the string.
while [ $start -le $end ]; do while [ "$start" -le "$end" ]; do
case "$start" in case "$start" in
[0-6]) blocks+="${reset}\033[3${start}m\033[4${start}m${block_width}" ;; [0-6]) blocks+="${reset}\033[3${start}m\033[4${start}m${block_width}" ;;
7) blocks+="${reset}\033[3${start}m\033[4${start}m${block_width}" ;; 7) blocks+="${reset}\033[3${start}m\033[4${start}m${block_width}" ;;
@ -2353,7 +2353,7 @@ info() {
# Call the function and update variable # Call the function and update variable
"get${2:-$1}" 2>/dev/null "get${2:-$1}" 2>/dev/null
eval output="\$${2:-$1}" eval output="\$${2:-"$1"}"
# Trim whitespace # Trim whitespace
output="$(trim "$output")" output="$(trim "$output")"
@ -2405,7 +2405,7 @@ info() {
# Prin {{{ # Prin {{{
prin() { prin() {
string="${1//$'\033[0m'}${2:+: $2}" string="${1//$'\033[0m'}${2:+: "$2"}"
# If $2 doesn't exist we format $1 as info # If $2 doesn't exist we format $1 as info
[ -z "$2" ] && local subtitle_color="$info_color" [ -z "$2" ] && local subtitle_color="$info_color"