diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-09-10 11:19:41 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-09-10 12:27:24 +0200 |
| commit | 2ba81afcc204024255ce548e2c4cc4aed5541093 (patch) | |
| tree | db0678886276546d511ecbbe45f2002b6d75be12 /etc/completion | |
| parent | 3794ce93be8216d8378df7b808ce7f53b1e05a53 (diff) | |
bash completion: Restore completion for 'guix system', etc.
Commit 538ca8dd65f0075cc65bcca18ed87f66a789290a introduced a second
'_guix_complete_subcommand' function, shadowing the existing one, which
broke sub-command completion for 'guix system', 'guix import', etc.
* etc/completion/bash/guix: Distinguish between '_guix_complete_command'
and '_guix_complete_subcommand'. Adjust users to call the right one.
Diffstat (limited to 'etc/completion')
| -rw-r--r-- | etc/completion/bash/guix | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix index 5aebd074e91..98d20484f78 100644 --- a/etc/completion/bash/guix +++ b/etc/completion/bash/guix | |||
| @@ -19,6 +19,19 @@ | |||
| 19 | # Bash completion for Guix commands. | 19 | # Bash completion for Guix commands. |
| 20 | 20 | ||
| 21 | declare _guix_available_packages | 21 | declare _guix_available_packages |
| 22 | declare _guix_commands | ||
| 23 | |||
| 24 | _guix_complete_command () | ||
| 25 | { | ||
| 26 | local word_at_point="${COMP_WORDS[$COMP_CWORD]}" | ||
| 27 | if [ -z "$_guix_commands" ] | ||
| 28 | then | ||
| 29 | # Cache the list of commands to speed things up. | ||
| 30 | _guix_commands="$(guix --help 2> /dev/null \ | ||
| 31 | | grep '^ ' | cut -c 2-)" | ||
| 32 | fi | ||
| 33 | COMPREPLY=($(compgen -W "$_guix_commands" -- "$word_at_point")) | ||
| 34 | } | ||
| 22 | 35 | ||
| 23 | _guix_complete_subcommand () | 36 | _guix_complete_subcommand () |
| 24 | { | 37 | { |
| @@ -146,19 +159,6 @@ _guix_complete_pid () | |||
| 146 | COMPREPLY=($(compgen -W "$pids" -- "$1")) | 159 | COMPREPLY=($(compgen -W "$pids" -- "$1")) |
| 147 | } | 160 | } |
| 148 | 161 | ||
| 149 | declare _guix_subcommands | ||
| 150 | |||
| 151 | _guix_complete_subcommand () | ||
| 152 | { | ||
| 153 | if [ -z "$_guix_subcommands" ] | ||
| 154 | then | ||
| 155 | # Cache the list of subcommands to speed things up. | ||
| 156 | _guix_subcommands="$(guix --help 2> /dev/null \ | ||
| 157 | | grep '^ ' | cut -c 2-)" | ||
| 158 | fi | ||
| 159 | COMPREPLY=($(compgen -W "$_guix_subcommands" -- "$word_at_point")) | ||
| 160 | } | ||
| 161 | |||
| 162 | _guix_complete () | 162 | _guix_complete () |
| 163 | { | 163 | { |
| 164 | local word_count=${#COMP_WORDS[*]} | 164 | local word_count=${#COMP_WORDS[*]} |
| @@ -176,7 +176,7 @@ _guix_complete () | |||
| 176 | 176 | ||
| 177 | case $COMP_CWORD in | 177 | case $COMP_CWORD in |
| 178 | 1) | 178 | 1) |
| 179 | _guix_complete_subcommand | 179 | _guix_complete_command |
| 180 | ;; | 180 | ;; |
| 181 | *) | 181 | *) |
| 182 | if _guix_is_command "package" | 182 | if _guix_is_command "package" |
| @@ -251,7 +251,7 @@ _guix_complete () | |||
| 251 | then | 251 | then |
| 252 | _guix_complete_file | 252 | _guix_complete_file |
| 253 | else | 253 | else |
| 254 | _guix_complete_subcommand | 254 | _guix_complete_command |
| 255 | fi | 255 | fi |
| 256 | elif _guix_is_command "container" | 256 | elif _guix_is_command "container" |
| 257 | then | 257 | then |
