Re: [PATCH] bash: support user-supplied completion scripts for user's git commands
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Jan 29, 2010, 20:04 UTC
- Message-ID
- <20100129200431.GE22101@spearce.org>
- In-Reply-To
- <20100129200033.GA32636@neumann>
SZEDER G?bor <szeder@ira.uka.de> wrote:
Show 14 quoted lines
>
> _git_lgm () {
> _git_log
> }
>
> Unfortunately, it doesn't work at all.
>
> In _git() first we have 'lgm' in $command, which is ok, but then comes
> this alias handling thing
>
> local expansion=$(__git_aliased_command "$command")
> [ "$expansion" ] && command="$expansion"
>
> which writes '!sh' into $command, and that doesn't look quite right__git_aliased_command is returning the first word out of the alias. I think we need to change this block here to:
case "$expansion" of \!*) : leave command as alias ;; '') : leave command alone ;; *) command="$expansion" ;; esac
Or something like that. Because an alias whose value starts with ! is a shell command to be executed, so we want to use _git_$command for completion, but other aliases are builtin commands and we should use their first word token (what __git_aliased_command returns) as the name of the completion function.
I think. :-)
-- Shawn.