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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

>> 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.

I meant former.  I actually am having a second thought.

I do not think this page should be the canonical place for config
and shell syntax lessons, but the value we have been using as an
example is a good candidate that an end user would encounter in the
real life and has need to do so.  

Perhaps it deserves some comment next to it?

; For the specified site, use "your_user" as the username, and
; invoke the helper, which is a short shell script.  Note that the
; value of the helper variable is enclosed in a double-quote pair,
; because it has a semicolon, which will cause the rest of the line
; discarded as a comment unless quoted.  The shell script in turn
; needs to quote various pieces of it in double quotes, each of
; which needs to be escaped with a backslash.

[credential "https://example.com";]
    username = your_user
    helper = "!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"


The more I think about it, the worse it becomes X-<

Do we expect that most of our users are comfortable editing
~/.gitconfig in their editor, or do they mostly work with the "git
config --global" command?

I have a feeling that my wishful-thinking answer, which is "former",
is not true in the real world.  Which means they not only need to
quote for the parser of the configuration file, but they then need
to quote that for the shell X-<.

    $ git config --global credential.https://example.com.helper \
	'"!f() { test \"$1\" = get && echo \"password=$(cat $HOME/.secret)\"; }; f"'

I wonder if it helps the users to have something that guides them to
figure out how they do the above.

> 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. :)

Yes, "these are values, go quote them as necessary" is certainly a
lot more attractive position to take.  But apparently that wasn't
all that helpful.

Thanks.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux