@@ -24,7 +24,7 @@ func writePreamble(buf io.StringWriter, name string) {
24
24
WriteStringAndCheck (buf , fmt .Sprintf (`
25
25
__%[1]s_debug()
26
26
{
27
- if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
27
+ if [[ -n ${BASH_COMP_DEBUG_FILE:- } ]]; then
28
28
echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
29
29
fi
30
30
}
@@ -187,7 +187,7 @@ __%[1]s_handle_reply()
187
187
PREFIX=""
188
188
cur="${cur#*=}"
189
189
${flags_completion[${index}]}
190
- if [ -n "${ZSH_VERSION}" ]; then
190
+ if [ -n "${ZSH_VERSION:- }" ]; then
191
191
# zsh completion needs --flag= prefix
192
192
eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
193
193
fi
@@ -272,7 +272,7 @@ __%[1]s_handle_flag()
272
272
273
273
# if a command required a flag, and we found it, unset must_have_one_flag()
274
274
local flagname=${words[c]}
275
- local flagvalue
275
+ local flagvalue=""
276
276
# if the word contained an =
277
277
if [[ ${words[c]} == *"="* ]]; then
278
278
flagvalue=${flagname#*=} # take in as flagvalue after the =
@@ -291,7 +291,7 @@ __%[1]s_handle_flag()
291
291
292
292
# keep flag value with flagname as flaghash
293
293
# flaghash variable is an associative array which is only supported in bash > 3.
294
- if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
294
+ if [[ -z "${BASH_VERSION:- }" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
295
295
if [ -n "${flagvalue}" ] ; then
296
296
flaghash[${flagname}]=${flagvalue}
297
297
elif [ -n "${words[ $((c+1)) ]}" ] ; then
@@ -363,7 +363,7 @@ __%[1]s_handle_word()
363
363
__%[1]s_handle_command
364
364
elif __%[1]s_contains_word "${words[c]}" "${command_aliases[@]}"; then
365
365
# aliashash variable is an associative array which is only supported in bash > 3.
366
- if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
366
+ if [[ -z "${BASH_VERSION:- }" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then
367
367
words[c]=${aliashash[${words[c]}]}
368
368
__%[1]s_handle_command
369
369
else
@@ -402,8 +402,8 @@ func writePostscript(buf io.StringWriter, name string) {
402
402
local commands=("%[1]s")
403
403
local must_have_one_flag=()
404
404
local must_have_one_noun=()
405
- local has_completion_function
406
- local last_command
405
+ local has_completion_function=""
406
+ local last_command=""
407
407
local nouns=()
408
408
409
409
__%[1]s_handle_word
@@ -605,7 +605,7 @@ func writeCmdAliases(buf io.StringWriter, cmd *Command) {
605
605
606
606
sort .Strings (cmd .Aliases )
607
607
608
- WriteStringAndCheck (buf , fmt .Sprint (` if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then` , "\n " ))
608
+ WriteStringAndCheck (buf , fmt .Sprint (` if [[ -z "${BASH_VERSION:- }" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then` , "\n " ))
609
609
for _ , value := range cmd .Aliases {
610
610
WriteStringAndCheck (buf , fmt .Sprintf (" command_aliases+=(%q)\n " , value ))
611
611
WriteStringAndCheck (buf , fmt .Sprintf (" aliashash[%q]=%q\n " , value , cmd .Name ()))
0 commit comments