From: Shawn O. Pearce Date: Sat, 08 Mar 2008 02:23:42 GMT Subject: Re: [PATCH] bash: __git_find_subcommand function Message-ID: <20080308022342.GY8410@spearce.org> In-Reply-To: <1204815512-18128-1-git-send-email-szeder@ira.uka.de> SZEDER Gbor wrote: > This enables us to remove code duplications from completion > functions for commands having subcommands. > > Signed-off-by: SZEDER Gábor > --- > 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.