From 3a03e1053e427e8403bc9a4c2fb4686d9d179991 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 29 Nov 2011 14:02:48 +0100 Subject: [PATCH] Fix gsu com_complete(). 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. --- misc/gsu/subcommand | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/misc/gsu/subcommand b/misc/gsu/subcommand index 911179e..7ba4850 100644 --- a/misc/gsu/subcommand +++ b/misc/gsu/subcommand @@ -400,7 +400,7 @@ gsu_getopts() _com_complete() { - local cmd n cword="$1" + local cmd n cword local -a words if (($# == 0)); then @@ -411,9 +411,13 @@ _com_complete() 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}" -- 2.39.2