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

Re: [PATCH 1/3] rev-parse: add --sq-quote to shell quote arguments

From
Christian Couder <chriscool@tuxfamily.org>
Date
Apr 25, 2009, 04:57 UTC
Message-ID
<200904250657.43344.chriscool@tuxfamily.org>
In-Reply-To
<7v8wlqii2y.fsf@gitster.siamese.dyndns.org>
Le vendredi 24 avril 2009, Junio C Hamano a écrit :
Show 11 quoted lines
> Christian Couder <chriscool@tuxfamily.org> writes:
> > @@ -30,6 +30,9 @@ OPTIONS
> >  	Only meaningful in `--parseopt` mode. Tells the option parser to echo
> >  	out the first `--` met instead of skipping it.
> >
> > +--sq-quote::
> > +	Use 'git-rev-parse' in shell quoting mode (see SQ-QUOTE section
> > below). +
>
> Hmph, I wonder how this interacts with the existing --sq option to the
> same command in the mental model of end users.

I just sent a new version where difference between --sq and --sq-quote are discussed.

Show 27 quoted lines
> > +Example
> > +~~~~~~~
> > +
> > +------------
> > +$ git rev-parse --sq-quote "'''" '"""' "arg with space"
> > + ''\'''\'''\''' '"""' 'arg with space'
> > +------------
>
> Yuck --- does asciidoc formats this correctly?
>
>     ... goes and tries ...
>
> Not very readable.  A better example might be to demonstrate something
> like this:
>
> 	$ cat >your-git-script.sh <<\EOF
> 	#!/bin/sh
> 	# quote user-supplied arguments
> 	args=$(git rev-parse --sq-quote "$@")
>         # and use it inside a handcrafted command line
>         command="git frotz -n24 $args"
>         eval "$command"
> 	EOF
>
> 	$ sh your-git-script.sh "a b'c"
>
> i.e, put stress on how to use it, not on how it works internally.
I agree your example is better. I used it in the v2 I just sent.

Thanks, Christian.

Previous: Christian Couder
Message 5 of 5 in “rev-parse: add --sq-quote to shell quote arguments”
  1. 1/3 rev-parse: add --sq-quote to shell quote argumentsChristian Couder, Apr 24, 2009
  2. Junio C HamanoApr 24, 2009
  3. Johannes SixtApr 24, 2009
  4. Christian CouderApr 25, 2009
  5. Christian CouderApr 25, 2009

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.