[PATCH] bash completion: Fix completion for commands and subcommands.

  • Done
  • quality assurance status badge
Details
2 participants
  • Oleg Pykhalov
  • Ludovic Courtès
Owner
unassigned
Submitted by
Oleg Pykhalov
Severity
normal
O
O
Oleg Pykhalov wrote on 19 Sep 2020 14:52
(address . guix-patches@gnu.org)(name . Oleg Pykhalov)(address . go.wigust@gmail.com)
20200919125251.3124-1-go.wigust@gmail.com
* etc/completion/bash/guix
(_guix_complete_command, _guix_complete_subcommand): Fix completion.
---
etc/completion/bash/guix | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

Toggle diff (27 lines)
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 98d20484f7..3bc9a48947 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -27,8 +27,7 @@ _guix_complete_command ()
if [ -z "$_guix_commands" ]
then
# Cache the list of commands to speed things up.
- _guix_commands="$(guix --help 2> /dev/null \
- | grep '^ ' | cut -c 2-)"
+ _guix_commands="$(guix --help 2> /dev/null | awk '/^ [a-z]/ { print $1 }')"
fi
COMPREPLY=($(compgen -W "$_guix_commands" -- "$word_at_point"))
}
@@ -36,9 +35,7 @@ _guix_complete_command ()
_guix_complete_subcommand ()
{
local command="${COMP_WORDS[1]}"
- local subcommands="$(${COMP_WORDS[0]} $command --help 2> /dev/null \
- | grep '^ [a-z]' \
- | sed -e's/^ \+\([a-z-]\+\).*$/\1/g')"
+ local subcommands="$(${COMP_WORDS[0]} $command --help 2> /dev/null | awk '/^ [a-z]/ { print $1 }')"
COMPREPLY=($(compgen -W "$subcommands" -- "${COMP_WORDS[$COMP_CWORD]}"))
}
--
2.28.0
L
L
Ludovic Courtès wrote on 21 Sep 2020 23:41
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 43509@debbugs.gnu.org)
871riuiz9d.fsf@gnu.org
Hi!

Oleg Pykhalov <go.wigust@gmail.com> skribis:

Toggle quote (3 lines)
> * etc/completion/bash/guix
> (_guix_complete_command, _guix_complete_subcommand): Fix completion.

Oops, I see. Could you mention in the commit log that this is a
followup to 3794ce93be8216d8378df7b808ce7f53b1e05a53, which broke it all
(right?).

Toggle quote (5 lines)
> # Cache the list of commands to speed things up.
> - _guix_commands="$(guix --help 2> /dev/null \
> - | grep '^ ' | cut -c 2-)"
> + _guix_commands="$(guix --help 2> /dev/null | awk '/^ [a-z]/ { print $1 }')"

Could we avoid awk?

Thanks,
Ludo’.
L
L
Ludovic Courtès wrote on 24 Sep 2020 17:57
(name . Oleg Pykhalov)(address . go.wigust@gmail.com)(address . 43509-done@debbugs.gnu.org)
87mu1f5frd.fsf@gnu.org
Hi,

Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (16 lines)
> Oleg Pykhalov <go.wigust@gmail.com> skribis:
>
>> * etc/completion/bash/guix
>> (_guix_complete_command, _guix_complete_subcommand): Fix completion.
>
> Oops, I see. Could you mention in the commit log that this is a
> followup to 3794ce93be8216d8378df7b808ce7f53b1e05a53, which broke it all
> (right?).
>
>> # Cache the list of commands to speed things up.
>> - _guix_commands="$(guix --help 2> /dev/null \
>> - | grep '^ ' | cut -c 2-)"
>> + _guix_commands="$(guix --help 2> /dev/null | awk '/^ [a-z]/ { print $1 }')"
>
> Could we avoid awk?

I went ahead and did that in 8e0c5033b17fcf1e4596ee9a3d52157900acc6fa.

Completion’s back! :-)

Ludo’.
Closed
?