Re: [PATCH] bash: __git_find_subcommand function
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Mar 8, 2008, 02:23 UTC
- Message-ID
- <20080308022342.GY8410@spearce.org>
- In-Reply-To
- <1204815512-18128-1-git-send-email-szeder@ira.uka.de>
SZEDER Gbor <szeder@ira.uka.de> wrote:
Show 16 quoted lines
> This enables us to remove code duplications from completion > functions for commands having subcommands. > > Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> > --- > This function does not return the index of the subcommand found on the > command line, which was in the $c variable previously. However, $c was > only used in if statements, like: > if [ $c -eq $COMP_CWORD -a -z "$command" ]; then > __gitcomp "cmd1 cmd2 cmd3" > fi > To my understanding the only(?) purpose of those if statements was to > prevent subcommands appearing again on the list of possible completions, > when there was one already on the command line. But [ -z $command ] is > sufficient to detect those cases, so we can actually omit > [ $c -eq $COMP_CWORD ]. Is it right, or am I missing something?
Yup, you understood it correctly. You found a cluster of "copy and paste programming" and I am happy to see it cleaned up. Thanks.
-- Shawn.