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

Re: [PATCH v6 2/3] Documentation: alias: add notes on shell expansion

From
Ian Wienand <iwienand@redhat.com>
Date
May 27, 2024, 00:22 UTC
Message-ID
<ZlPSKfzHejm-Z5Pn@fedora19.localdomain>
In-Reply-To
<xmqqa5kcduis.fsf@gitster.g>
On Sun, May 26, 2024 at 04:26:51PM -0700, Junio C Hamano wrote:
> As I keep saying over multiple iterations, the above three bullet
> points stress too much on the minute implementation detail while
> failing to tell readers that the end-user alias receives the rest of
> the command line as arguments.

OK, I can agree that perhaps I've been a bit to fixated on the addition of "$@" and the mechanics of this. I will propose again with this trimmed. What I didn't have to help me at the time was the full command in GIT_TRACE, which I think is probably a more appropriate way to communicate these details of what's actually hitting the exec calls.

> Of course the simplest one-liner, if you had the "one" script
> already stored in the file, is to say

So the reason I fell into this, and I wonder how much this plays out for others too, is that shipping these workflow bits as stand-alone scripts would mean no !shell tricks required, it's all very logical and I would never have looked at any of this :) However, when all you have is a hammer ... since a git config .inc file was needed for other things, it has been overloaded into essentially being mini package-manger that avoids having to install additional dependencies; one-liner shell script at a time :)

> You can do one of two easy things.
> 
>     $ sh -c 'echo "$1" | grep "$2"' -      1 2

Ok, I think "sh -c" in ! aliases is a bit confusing, personally. You end up two shells nested deep, and you really have to explain what's going on with $0; it's very easy to miss.

>     $ e(){ echo "$1" | grep "$2"; };e      1 2

This method, which is used elsewhere in the docs as well, I think makes the most sense. So I've left that in as the example.

-i
Previous: Junio C HamanoNext: Ian Wienand
Message 37 of 43 in “alias: document caveats and add trace of prepared command”
  1. alias: document caveats and add trace of prepared commandIan Wienand, May 22, 2024
  2. Eric SunshineMay 22, 2024
  3. Junio C HamanoMay 22, 2024
  4. Ian WienandMay 23, 2024
  5. 1/3 Documentation: alias: rework notes into pointsIan Wienand, May 23, 2024
  6. 2/3 Documentation: alias: add notes on shell expansionIan Wienand, May 23, 2024
  7. 3/3 run-command: show prepared commandIan Wienand, May 23, 2024
  8. Eric SunshineMay 23, 2024
  9. Ian WienandMay 23, 2024
  10. 1/3 Documentation: alias: rework notes into pointsIan Wienand, May 23, 2024
  11. 2/3 Documentation: alias: add notes on shell expansionIan Wienand, May 23, 2024
  12. 3/3 run-command: show prepared commandIan Wienand, May 23, 2024
  13. Junio C HamanoMay 23, 2024
  14. Junio C HamanoMay 23, 2024
  15. Junio C HamanoMay 24, 2024
  16. Ian WienandMay 24, 2024
  17. Junio C HamanoMay 24, 2024
  18. Ian WienandMay 24, 2024
  19. Junio C HamanoMay 24, 2024
  20. Ian WienandMay 25, 2024
  21. Junio C HamanoMay 23, 2024
  22. 1/3 Documentation: alias: rework notes into pointsIan Wienand, May 24, 2024
  23. 2/3 Documentation: alias: add notes on shell expansionIan Wienand, May 24, 2024
  24. 3/3 run-command: show prepared commandIan Wienand, May 24, 2024
  25. Junio C HamanoMay 24, 2024
  26. Junio C HamanoMay 24, 2024
  27. Ian WienandMay 25, 2024
  28. 1/3 Documentation: alias: rework notes into pointsIan Wienand, May 25, 2024
  29. 2/3 Documentation: alias: add notes on shell expansionIan Wienand, May 25, 2024
  30. 3/3 run-command: show prepared commandIan Wienand, May 25, 2024
  31. Junio C HamanoMay 25, 2024
  32. Junio C HamanoMay 25, 2024
  33. Ian WienandMay 25, 2024
  34. 1/3 Documentation: alias: rework notes into pointsIan Wienand, May 25, 2024
  35. 2/3 Documentation: alias: add notes on shell expansionIan Wienand, May 25, 2024
  36. Junio C HamanoMay 26, 2024
  37. Ian WienandMay 27, 2024
  38. 3/3 run-command: show prepared commandIan Wienand, May 25, 2024
  39. Junio C HamanoMay 26, 2024
  40. 1/3 Documentation: alias: rework notes into pointsIan Wienand, May 27, 2024
  41. 2/3 Documentation: alias: add notes on shell expansionIan Wienand, May 27, 2024
  42. Junio C HamanoMay 27, 2024
  43. 3/3 run-command: show prepared commandIan Wienand, May 27, 2024

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.