On Mon, 22 Oct 2012 04:20:28 -0700 (PDT)
Artem Grebenkin <gre...@googlemail.com> wrote:

> there is some nice feature in bash if I would like to run next
> command with last executed commands arguments *$(history -p !!:2*)*:
> So for example:
> I have alias in .bashrc *alias ll="ls -la $(history -p !!:2*)"*
> >* ls dev prod*
> > *ll*
> *ls -la dev prod*
> 
> So this expanding dont seems to work in .gitconfig. If I use *da
> =!"git add $(history -p !!:2*)"*, git says unable to expand !!:2*.
> My use case is, after I ran *git diff test.py test1.py* and checked
> all changes stage only this files, so I should then run *git add
> test.py test1.py*. Instead I'd like to run* git ad*.

Git (on POSIX) uses "/bin/sh" when building the actual command to be
executed by the shell.  I suspect your /bin/sh is symlinked to
something other than /bin/bash (for instance, on a typical contemporary
Debian system /bin/sh is a symlink to /bin/dash which is a
stripped-down but very fast no-frills implementation).

Unfortunately, I don't see any means to explicitly tell Git which shell
it should use (I supposed there might be a configuration option, like
"shell.cmd", for this, but failed to find anything like that), so your
options appear to be limited:
1) Implement support for configuring the shell in Git and send the
   patch upstream -- this is the best one, IMO.
2) Do not use non-standard shell features.
3) Create a bunch of support scripts which have "#!/bin/bash" as their
   shebang line and call them from your aliases.
4) Embed a call to /bin/bash into your aliases, like
   "/bin/bash -c 'git add $(history -p !!:2*)'"
   This should work but you must be aware of the double interpretation
   of the command text that will happen -- first by /bin/sh, then
   by /bin/bash.  Running your alias under GIT_TRACE=1 in the
   environment might help with debugging this.
5) Make system shell be /bin/bash.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to