From 46d356bc055978057542e999892ec6e0cf1c0153 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 17 Apr 2017 16:19:38 +0200 Subject: [PATCH] subcommand: Fix and document return value of gsu_complete_options(). The value returned in $ret was undocumented so far. And it did not make sense either: We used to return 0 if the current word does not start with a hyphen, and the number of options in the given optstring otherwise. Hence the value of zero is ambiguous. Nobody needs the number of options anyway, so let's simply return 0 or 1, and document this. --- subcommand | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subcommand b/subcommand index a07f414..956fb5c 100644 --- a/subcommand +++ b/subcommand @@ -187,6 +187,8 @@ _gsu_print_available_commands() # Print all options of the given optstring to stdout if the word in the current # command line begins with a hyphen character. +# +# Returns 0 if the current word does not start with a hyphen, one otherwise. gsu_complete_options() { local opts="$1" cword="$2" cur opt @@ -198,13 +200,12 @@ gsu_complete_options() ret=0 [[ ! "$cur" == -* ]] && return - ret=0 for ((i=0; i < ${#opts}; i++)); do opt="${opts:$i:1}" [[ "$opt" == ":" ]] && continue printf "%s" "-$opt " - let ret++ done + ret=1 } com_prefs_options='e' -- 2.30.2