-
Notifications
You must be signed in to change notification settings - Fork 400
Description
Describe the bug
When the command completion function starts running
there are three variables automatically setting $1, $2, $3.
and $2 is not always the same as ${COMP_WORDS[COMP_CWORD]}.
-
if
$2value is a member of$COMP_WORDBREAKSvariable
then it's value is empty by defaultex) command --foo=[tab]
$2: (empty)${COMP_WORDS[COMP_CWORD]}:= -
if
$2value start with"or'(single or double quote)
then it's quote removed ("foo-->foo)ex) command --foo "bar[tab]
$2:bar${COMP_WORDS[COMP_CWORD]}:"bar
this is an intended work for making completion function simpler
but if i use sudo in front of a command then
$2 value is always the same as ${COMP_WORDS[COMP_CWORD]}
This is a different behavior to the bash default and problematic.
and ends up can not use $2 variable and force to use
${COMP_WORDS[COMP_CWORD]} to support sudo
Versions
- Operating system name/distribution and version:
Operating System: Ubuntu 22.04.1 LTS
Kernel: Linux 5.15.0-43-generic
Architecture: x86-64 - bash version: 5.1.16(1)-release
- bash-completion version: 2.11