@@ -392,26 +392,26 @@ _comp_split()
392392# OPTIONS
393393# -a Append to the array
394394# -v arr Store the results to the array ARR. The default is `COMPREPLY`.
395+ # The array name should not start with an underscores "_", which is
396+ # internally used. The array name should not be either "IFS" or
397+ # "OPT{IND,ARG,ERR}".
395398# -F sep Set a set of separator characters (used as IFS in evaluating
396399# `compgen'). The default separator is $' \t\n'. Note that this is
397400# not the set of separators to delimit output of `compgen', but the
398401# separators in evaluating the expansions of `-W '...'`, etc. The
399402# delimiter of the output of `compgen` is always a newline.
400- # -l The same as -F $'\n'.
403+ # -l The same as -F $'\n'. Use lines as words in evaluating compgen.
401404# -c cur Set a word used as a prefix to filter the completions. The default
402405# is ${cur-}.
403- # -R The same as -c ''.
404- # @param $1 array_name The array name
405- # The array name should not start with an underscores "_", which is
406- # internally used. The array name should not be either "IFS" or
407- # "OPT{IND,ARG,ERR}".
408- # @param $2... args The arguments that are passed to compgen
406+ # -R The same as -c ''. Use raw outputs without filtering.
407+ # @param $1... args Arguments that are passed to compgen
408+ #
409409# Note: References to positional parameters $1, $2, ... (such as -W '$1')
410410# will not work as expected because these reference the arguments of
411411# `_comp_compgen' instead of those of the caller function. When there are
412412# needs to reference them, save the arguments to an array and reference the
413413# array instead. The array option `-V arr` in bash >= 5.3 should be instead
414- # specified as `-v arr` as a part of `_comp_compgen` options.
414+ # specified as `-v arr` as a part of the `_comp_compgen` options.
415415# @var[in] cur Used as the default value of a prefix to filter the
416416# completions.
417417_comp_compgen ()
@@ -425,7 +425,7 @@ _comp_compgen()
425425 a) _append=set _split_options+=(-a) ;;
426426 v)
427427 if [[ $OPTARG == @ (* [^_a-zA-Z0-9]* | [0-9]* | ' ' | _* | IFS| OPTIND| OPTARG| OPTERR) ]]; then
428- printf ' bash_completion: %s: invalid array name `%s' \' ' .\n' " $FUNCNAME " " -v $OPTARG " >&2
428+ printf ' bash_completion: %s: -v: invalid array name `%s' \' ' .\n' " $FUNCNAME " " $OPTARG " >&2
429429 return 2
430430 fi
431431 _var=$OPTARG
@@ -451,11 +451,11 @@ _comp_compgen()
451451 # in bash < 5.0, where unquoted $* in conditional command did not honor
452452 # IFS, was a bug.
453453 local IFS=$' \t\n '
454- [[ $* == * \$ [0-9]* || $* == * \$\{ [0-9]* ]]
455- then
456454 # Note: extglob *\$?(\{)[0-9]* can be extremely slow when the string
457455 # "${*:2:_nopt}" becomes longer, so we test \$[0-9] and \$\{[0-9]
458456 # separately.
457+ [[ $* == * \$ [0-9]* || $* == * \$\{ [0-9]* ]]
458+ then
459459 printf ' bash_completion: %s: positional parameter $1, $2, ... do not work inside this function.\n' " $FUNCNAME " >&2
460460 return 2
461461 fi
0 commit comments