Re: Weird behavior of shell variables in git aliases
- From
Lasse Makholm <lasse.makholm@gmail.com>
- Date
- Mar 22, 2011, 22:22 UTC
- Message-ID
- <AANLkTinvP1TvhNBsN+Y3wyhzg+qampa6J=3NMfwr76a=@mail.gmail.com>
- In-Reply-To
- <20110322183201.GA22534@sigill.intra.peff.net>
On 22 March 2011 19:32, Jeff King <peff@peff.net> wrote:
Show 6 quoted lines
> On Tue, Mar 22, 2011 at 10:57:08AM -0700, Junio C Hamano wrote: >> is no longer true; nobody sane would expect that if you made them realize >> that "simply appended" already. Just dropping that sentence would make >> the resulting text flow much better. > > Agreed, your version is better.
Good points...
Show 7 quoted lines
>> I personally think the former "sh -c <str> -" is the more traditional and >> well understood form (iow, an idiom) for people who breathe shells. > > Yeah, that is probably true. One advantage of the function idiom is that > it doesn't happen inside single-quotes, so it's one less layer of > quoting to deal with. And of course it saves a shell invocation. So I > think mentioning both is reasonable.
As one of those shell-breathing people I prefer the function-style for its lack of quotes:
git config alias.foo = !foo () { echo $# args: $1, $2 and $3; }; fooWhlie we're at it, is "sh -c ... -" and "sh -c ... --" equally portable, I wonder?
Show 9 quoted lines
>> > +---------------------- >> > +alias.foo = !echo $# args: $1, $2 and $3 >> > +---------------------- >> >> While I totally agree with the formatting advice you gave here, we may >> want to avoid this notation; neither "git config alias.foo = !echo ..." >> nor writing "alias.foo = ..." in .git/config file would work. > > Yeah, I didn't even think about that, but you are right.
Good point, I was wondering about that but decided to take my clue from existing examples of the same notation...
Right, I'll sleep() on it and cook a patch tomorow, attempting to take all of the above into account...
-- /Lasse