git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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; }; foo

Whlie 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
Previous: Jeff KingNext: Junio C Hamano
Message 17 of 20 in “Weird behavior of shell variables in git aliases”
  1. Dun PealMar 21, 2011
  2. Jeff KingMar 21, 2011
  3. Junio C HamanoMar 21, 2011
  4. Junio C HamanoMar 21, 2011
  5. Lasse MakholmMar 22, 2011
  6. Jeff KingMar 22, 2011
  7. Lasse MakholmMar 22, 2011
  8. Ævar Arnfjörð BjarmasonMar 22, 2011
  9. Jeff KingMar 22, 2011
  10. Jeff KingMar 22, 2011
  11. Lasse MakholmMar 22, 2011
  12. Jeff KingMar 22, 2011
  13. Lasse MakholmMar 22, 2011
  14. Dun PealMar 22, 2011
  15. Junio C HamanoMar 22, 2011
  16. Jeff KingMar 22, 2011
  17. Lasse MakholmMar 22, 2011
  18. Junio C HamanoMar 23, 2011
  19. Junio C HamanoMar 22, 2011
  20. Junio C HamanoMar 22, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.