Skip to content

Use sudo with complete -C commands #631

Closed
@cykerway

Description

@cykerway

Describe the bug

When a command is completed with complete -C, sudo complete is not working.

To reproduce

$ complete -C 'echo' foo
$ sudo foo <tab>

Gives warning:

-bash: compgen: warning: -C option may not work as you expect

Expected behavior

No warning message thrown, and sudo foo completes the same way as foo.

Versions (please complete the following information)

  • [linux] Operating system name/distribution and version:
  • [5.1] bash version, echo "$BASH_VERSION":
  • [2.11] bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"):

Additional context

man bash says about compgen:

When using the -F or -C options, the various shell variables set by the programmable completion facilities, while available, will not have useful values.

_command_offset knows about -F but not -C:

...
if [[ ${cspec#* -F } != "$cspec" ]]; then
...

Debug trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions