Thread (12 messages) flat view 12 messages, 4 authors, 2016-06-15

Re: [PATCH] bash: support user-supplied completion scripts for user's git commands

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:48:07

Possibly related (same subject, not in this thread)

SZEDER G?bor [off-list ref] wrote:
_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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help