Re: [PATCH 2/2] gitcredentials(7): make shell-snippet example more realistic
- From
Jeff King <peff@peff.net>
- Date
- May 1, 2020, 06:35 UTC
- Message-ID
- <20200501063513.GB26128@coredump.intra.peff.net>
- In-Reply-To
- <20200501063207.GA26128@coredump.intra.peff.net>
On Fri, May 01, 2020 at 02:32:07AM -0400, Jeff King wrote:
Show 15 quoted lines
> > 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. :)
-Peff