[Top][All Lists]

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

Re: [PATCH] Fix escaping of \034 (^\) in paths for \w, \W, and \s

From: Chet Ramey
Subject: Re: [PATCH] Fix escaping of \034 (^\) in paths for \w, \W, and \s
Date: Mon, 14 Mar 2022 15:06:13 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.2

On 3/12/22 10:35 AM, Koichi Murase wrote:
I have tried the latest devel branch to see the behavior of the
escaping of directory names (\w, \W) in the prompt implemented in the
recent commit b4e5e550, which was originally discussed in the thread
[1].  It now mostly works as expected, but I noticed that the escaping
of \034 is incomplete.

[1] https://lists.gnu.org/archive/html/bug-bash/2022-01/msg00051.html


Bash Version: 5.2 (devel branch)
Commit b6a567e7f13406952cbb1d1adb2f00b2260a871e
Commit b4e5e5505cc4495c6237c32a65ba62ebcc497b31


   The escaping of the invisible characters in the directory names in
   the prompt escapes \w, \W and the path in \s has been implemented in
   the function `sh_backslash_quote_for_double_quotes'
   (lib/sh/shquote.c:323) in commit b4e5e550.  The primary purpose of
   the function `sh_backslash_quote_for_double_quotes' is to quote
   special characters in double quotes with a backslash.  When the
   escaping of the invisible characters are turned on by the argument
   FLAG, a backslash in the visible representation of $'\034', '^\', it
   not properly escaped by another backslash.  This may break the
   escaping of the succeeding special character.

I did it this way precisely to avoid two passes through the string. If
that's not an issue, you can just call sh_strvis and then
sh_backslash_quote_for_double_quotes on the result.

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

reply via email to

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