[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem in var substitution with / and \
From: |
Chet Ramey |
Subject: |
Re: Problem in var substitution with / and \ |
Date: |
Mon, 14 Jan 2019 09:00:08 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 1/14/19 6:51 AM, Jean-François Berroyer wrote:
> Bash Version: 5.0
> Patch Level: 0
> Release Status: release
>
> Description:
> If a variable contains one '/' (or many)
> and if this '/' is escaped with '\' by substitution mechanism
> and if the escaped variable is concatenated with a string containing '/' as
> prefix, and another string containing '/' as suffix
> then all characters in prefix and suffix are escaped with '\'
> The problem does not occurs in a "" context
>
> Repeat-By:
> URL=http://example.com
> ESCAPED_URL=${URL//\//\\\/}
> echo 'My URL: '$ESCAPED_URL' ... OK'
> echo '/My URL: http:\/\/example.com ... OK/'
> echo "/My URL: $ESCAPED_URL ... OK/"
> echo '/My URL: '$ESCAPED_URL' ... KO/'
See if this fixes it:
http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00087.html
--
``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/