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

Re: [PATCH 2/2] gitcredentials(7): make shell-snippet example more realistic

From
Jeff King <peff@peff.net>
Date
May 1, 2020, 07:32 UTC
Message-ID
<20200501073222.GB27392@coredump.intra.peff.net>
In-Reply-To
<20200501063513.GB26128@coredump.intra.peff.net>
On Fri, May 01, 2020 at 02:35:13AM -0400, Jeff King wrote:
Show 28 quoted lines
> On Fri, May 01, 2020 at 02:32:07AM -0400, Jeff King wrote:
> 
> > > All of them make sense, but I do not think we want to encourage that
> > > loose style of passing unquoted argument to echo to lose embedded
> > > $IFS spaces that is not a SP.
> > 
> > You mean dropping the quotes in the first patch?
> > 
> > Doing:
> > 
> >   echo "password=$(cat $HOME/.secret)"
> > 
> > already eats some trailing whitespace, though I guess if you have
> > newlines in your password you are beyond help anyway.
> > 
> > I can add back in the quoted \", though it does make the code slightly
> > harder to read.
> 
> Or did you mean passing $1 in the test call? It definitely isn't good
> shell practice, but we know that we're getting a single-word action from
> Git, per the protocol.
> 
> Fully quoting, it looks like this:
> 
>   helper = "!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"
> 
> which IMHO is getting a little hard to read. I think that's part of why
> I gave such an unfinished example in the first place. :)

So I dunno. That's ugly, but I don't think is worth nitpicking over more. So here it is with indentation and full-on quoting.

  [1/2]: gitcredentials(7): clarify quoting of helper examples
  [2/2]: gitcredentials(7): make shell-snippet example more realistic
 Documentation/gitcredentials.txt | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
-Peff
Previous: Jeff KingNext: Jeff King
Message 12 of 18 in “doc: fix quoting bug in credential cache example”
  1. doc: fix quoting bug in credential cache exampledouglas.fuller@gmail.com, Apr 30, 2020
  2. Junio C HamanoApr 30, 2020
  3. Jeff KingMay 1, 2020
  4. Jeff KingMay 1, 2020
  5. 1/2 gitcredentials(7): clarify quoting of helper examplesJeff King, May 1, 2020
  6. Andreas SchwabMay 1, 2020
  7. Jeff KingMay 1, 2020
  8. 2/2 gitcredentials(7): make shell-snippet example more realisticJeff King, May 1, 2020
  9. Junio C HamanoMay 1, 2020
  10. Jeff KingMay 1, 2020
  11. Jeff KingMay 1, 2020
  12. Jeff KingMay 1, 2020
  13. 1/2 gitcredentials(7): clarify quoting of helper examplesJeff King, May 1, 2020
  14. 2/2 gitcredentials(7): make shell-snippet example more realisticJeff King, May 1, 2020
  15. Junio C HamanoMay 1, 2020
  16. douglas.fuller@gmail.comMay 1, 2020
  17. Junio C HamanoMay 1, 2020
  18. Jeff KingMay 1, 2020

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.