[Top][All Lists]

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

Re: shquote.c incorrectly escapes comma, but not tilde

From: Chet Ramey
Subject: Re: shquote.c incorrectly escapes comma, but not tilde
Date: Tue, 25 Apr 2017 14:59:58 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 4/25/17 10:10 AM, address@hidden wrote:

> Bash Version: 4.3
> Patch Level: 46
> Release Status: release
> Description:
>       When using any functionality that triggers shquote the
>       comma character is escaped with a backslash which bash
>       doesn't strip when the quoted text is reused, while
>       tilde isn't despite it causing home directory expansion.

The documentation states "reused as shell input", which isn't quite the
same as the output of a word expansion.  The backslash quoting the comma,
which serves to inhibit brace expansion, is removed just fine if the
string is used as shell input.

As for the tilde:

$ echo $(printf "%q\n" "~" "a,b")
\~ a\,b
$ eval echo $(printf "%q\n" "~" "a,b")
~ a,b

The same explanation suffices for why the tilde is quoted with a backslash.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]