It should work also if set -u was given. Currently this fails if
_com_complete() is called with no arguments.
Moreover, the first argument, if it is provided, should be a number
but we missed to check this.
_com_complete()
{
- local cmd n cword="$1"
+ local cmd n cword
local -a words
if (($# == 0)); then
candidates=(\$($0 complete "\$COMP_CWORD" "\${COMP_WORDS[@]}"));
COMPREPLY=(\$(compgen -W "\${candidates[*]}" -- "\$cur"));
EOF
+ ret=$GSU_SUCCESS
+ return
fi
- [[ -z "$cword" ]] && return
+ cword="$1"
+ gsu_is_a_number "$cword"
+ (($ret < 0)) && return
if (($cword <= 1)); then
_gsu_available_commands
echo "${result}"