Skip to content

Commit d0a0eb5

Browse files
committed
*: avoid more errors in nounset mode
Refs scop#44
1 parent b807460 commit d0a0eb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+254
-246
lines changed

bash_completion

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -905,8 +905,8 @@ _parse_usage()
905905
# @param $1 prefix
906906
_signals()
907907
{
908-
local -a sigs=($(compgen -P "$1" -A signal "SIG${cur#$1}"))
909-
COMPREPLY+=("${sigs[@]/#${1}SIG/${1}}")
908+
local -a sigs=($(compgen -P "${1-}" -A signal "SIG${cur#${1-}}"))
909+
COMPREPLY+=("${sigs[@]/#${1-}SIG/${1-}}")
910910
}
911911

912912
# This function completes on known mac addresses
@@ -1134,7 +1134,7 @@ _expand()
11341134
_pnames()
11351135
{
11361136
local -a procs
1137-
if [[ $1 == -s ]]; then
1137+
if [[ ${1-} == -s ]]; then
11381138
procs=($(command ps axo comm | command sed -e 1d))
11391139
else
11401140
local line i=-1 ifs=$IFS
@@ -1317,7 +1317,7 @@ _usergroup()
13171317
prefix=${cur%%*([^:])}
13181318
prefix=${prefix//\\/}
13191319
local mycur="${cur#*[:]}"
1320-
if [[ $1 == -u ]]; then
1320+
if [[ ${1-} == -u ]]; then
13211321
_allowed_groups "$mycur"
13221322
else
13231323
local IFS=$'\n'
@@ -1329,7 +1329,7 @@ _usergroup()
13291329
# Reply with a list of unprefixed groups since readline with split on :
13301330
# and only replace the 'gr' part
13311331
local mycur="${cur#*:}"
1332-
if [[ $1 == -u ]]; then
1332+
if [[ ${1-} == -u ]]; then
13331333
_allowed_groups "$mycur"
13341334
else
13351335
local IFS=$'\n'
@@ -1341,7 +1341,7 @@ _usergroup()
13411341
# Don't suffix with a : because readline will escape it and add a
13421342
# slash. It's better to complete into 'chown username ' than 'chown
13431343
# username\:'.
1344-
if [[ $1 == -u ]]; then
1344+
if [[ ${1-} == -u ]]; then
13451345
_allowed_users "$cur"
13461346
else
13471347
local IFS=$'\n'
@@ -1697,6 +1697,7 @@ _known_hosts_real()
16971697
# https://man.openbsd.org/sshd.8#SSH_KNOWN_HOSTS_FILE_FORMAT
16981698
for i in "${kh[@]}"; do
16991699
while read -ra tmpkh; do
1700+
((${#tmpkh[@]} == 0)) && continue
17001701
set -- "${tmpkh[@]}"
17011702
# Skip entries starting with | (hashed) and # (comment)
17021703
[[ $1 == [\|\#]* ]] && continue
@@ -1747,7 +1748,7 @@ _known_hosts_real()
17471748
fi
17481749

17491750
# Add hosts reported by avahi-browse, if desired and it's available.
1750-
if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] &&
1751+
if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI-} ]] &&
17511752
type avahi-browse &>/dev/null; then
17521753
# The original call to avahi-browse also had "-k", to avoid lookups
17531754
# into avahi's services DB. We don't need the name of the service, and
@@ -2009,7 +2010,7 @@ _longopt()
20092010
[[ $line =~ --[-A-Za-z0-9]+=? ]] &&
20102011
printf '%s\n' ${BASH_REMATCH[0]}
20112012
done)" -- "$cur"))
2012-
[[ $COMPREPLY == *= ]] && compopt -o nospace
2013+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
20132014
elif [[ $1 == *@(rmdir|chroot) ]]; then
20142015
_filedir -d
20152016
else

completions/2to3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _2to3()
2828

2929
if [[ $cur == -* ]]; then
3030
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
31-
[[ $COMPREPLY == *= ]] && compopt -o nospace
31+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
3232
return
3333
fi
3434

completions/7z

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ _7z()
9191
COMPREPLY=($(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}=
9292
-o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y' \
9393
-- "$cur"))
94-
[[ $COMPREPLY == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] ||
94+
[[ ${COMPREPLY-} == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] ||
9595
compopt -o nospace
9696
return
9797
fi

completions/_mock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ _mock()
5959

6060
if [[ $cur == -* ]]; then
6161
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
62-
[[ $COMPREPLY == *= ]] && compopt -o nospace
62+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
6363
else
6464
_filedir '@(?(no)src.r|s)pm'
6565
fi

completions/_mount.linux

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ _mount()
207207
# COMP_WORDBREAKS is a real pain in the ass
208208
prev="${prev##*[$COMP_WORDBREAKS]}"
209209
$split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"})
210-
[[ $COMPREPLY == *= ]] && compopt -o nospace
210+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
211211
return
212212
;;
213213
esac
@@ -217,7 +217,7 @@ _mount()
217217
--fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s
218218
--read-only --rw -L -U --types --test-opts --options --bind --rbind
219219
--move' -- "$cur"))
220-
[[ $COMPREPLY ]] && return
220+
[[ ${COMPREPLY-} ]] && return
221221
fi
222222

223223
[[ $cur == \\ ]] && cur="/"

completions/_repomanage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _repomanage()
1414

1515
if [[ $cur == -* ]]; then
1616
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
17-
[[ $COMPREPLY == *= ]] && compopt -o nospace
17+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
1818
else
1919
_filedir -d
2020
fi

completions/_su

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _su()
3030

3131
if [[ $cur == -* ]]; then
3232
COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
33-
[[ $COMPREPLY == *= ]] && compopt -o nospace
33+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
3434
return
3535
fi
3636

completions/_udevadm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ _udevadm()
6969
if [[ $cur == -* ]]; then
7070
COMPREPLY=($(compgen -W \
7171
'$("$1" $udevcmd --help 2>/dev/null | _parse_help -)' -- "$cur"))
72-
[[ $COMPREPLY == *= ]] && compopt -o nospace
72+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
7373
fi
7474
} &&
7575
complete -F _udevadm udevadm

completions/_umount.linux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ _umount()
128128
if [[ $cur == -* ]]; then
129129
COMPREPLY=($(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l
130130
--no-canonicalize --fake' -- "$cur"))
131-
[[ $COMPREPLY ]] && return
131+
[[ ${COMPREPLY-} ]] && return
132132
fi
133133

134134
if [[ -r /proc/mounts ]]; then

completions/_yum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ _yum()
136136

137137
if [[ $cur == -* ]]; then
138138
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
139-
[[ $COMPREPLY == *= ]] && compopt -o nospace
139+
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
140140
fi
141141
} &&
142142
complete -F _yum yum

0 commit comments

Comments
 (0)