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.
# 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
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'