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

Re: Shell quoting

From
HAH. Peter Anvin <hpa@zytor.com>
Date
Sep 15, 2005, 20:18 UTC
Message-ID
<4329D705.8050101@zytor.com>
In-Reply-To
<7vll1yyusn.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 12 quoted lines
> "H. Peter Anvin" <hpa@zytor.com> writes:
> 
> 
>>Linus Torvalds wrote:
>>
>>>Does anybody really still use tcsh? It's a broken mess.
>>>
>>
>>Yes.
> 
> Yes to "still use", or yes to "broken mess" ;-)?
> 
Both :)
Show 15 quoted lines
>>>Junio's "sq_quote()" works wonderfully on any valid shells. The fact
>>>that tcsh expands ! even inside single quotes is just pure
>>>braindamage.
>>
>>>You could expand "sq_quote" to handle '!' and '\' characters the exact
>>>same way it handles the single tick (end single-tick quoting, do \! or \\
>>>and start single-tick quoting again) and that might be good enough for
>>>tcsh.
>>
>>It seems easier to just \-escape any special characters.
> 
> I am sympathetic.  The beauty of sq_quote() comes directly from
> the behaviour of single quoting rules of "any valid shells" --
> there is no need to maintain a list of special characters.  Just
> single quote itself is special and nothing else.

Well, in the patch I just posted I simply \-escape a blacklist of characters. It should be quite safe, since the blacklist consists of all ASCII characters that aren't known to be regularly used on the command line.

	-hpa
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 12 in “Remove shell dependency in env.c”
  1. Remove shell dependency in env.cH. Peter Anvin, Sep 15, 2005
  2. Junio C HamanoSep 15, 2005
  3. H. Peter AnvinSep 15, 2005
  4. Shell quotingH. Peter Anvin, Sep 15, 2005
  5. Linus TorvaldsSep 15, 2005
  6. H. Peter AnvinSep 15, 2005
  7. Junio C HamanoSep 15, 2005
  8. H. Peter AnvinSep 15, 2005
  9. Junio C HamanoSep 15, 2005
  10. Linus TorvaldsSep 15, 2005
  11. Junio C HamanoSep 16, 2005
  12. rsh.c env and quoting cleanup, take 2H. Peter Anvin, Sep 15, 2005

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.