Re: [PATCH] expand: Fix naked backslah leakage

Harald van Dijk <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
On 27/04/2024 12:02, Herbert Xu wrote:
> Naked backslashes in patterns may incorrectly unquote subsequent
> wild characters that are themselves quoted.  Fix this by adding
> an extra backslash when necessary.
> 
> Test case:
> 
> 	a="\\*bc"; b="\\"; c="*"; echo "<${a##$b"$c"}>"
> 
> Old result:
> 
> 	<>
> 
> New result:
> 
> 	<bc>

The correct result here, I believe, is <\*bc>. The backslash means the 
next character is taken as literal, even if that character is already 
also taken as literal because of the quoting. There is nothing to cause 
the backslash to be taken literally. The result should be that only a 
leading * is removed from $a.

Cheers,
Harald van Dijk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.