From: Harald van Dijk <harald@gigawatt.nl>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: DASH Mailing List <dash@vger.kernel.org>
Subject: Re: [PATCH] expand: Fix naked backslah leakage
Date: Sat, 27 Apr 2024 14:46:06 +0100 [thread overview]
Message-ID: <2bf68a06-2050-4e5c-8e5e-3a703b21c9ee@gigawatt.nl> (raw)
In-Reply-To: <Zizt6ZdJrdSFVBhT@gondor.apana.org.au>
On 27/04/2024 13:22, Herbert Xu wrote:
> On Sat, Apr 27, 2024 at 01:12:19PM +0100, Harald van Dijk wrote:
>>
>> 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.
>
> While I do see the logic in your reasoning, no other shell implements
> this behaviour:
I'm aware this isn't what most shells do, but it's not quite the case
that no other shell implements this.
> *sh -c 'a="*bc"; b="\\"; c="*"; echo "<${a##$b"$c"}>"'
>
> always produces <*bc> across all shells on my system.
This produces <bc> with my shell, at least.
If we are comparing what other shells do, it is probably worth pointing
out that shells disagree on your original example.
a="\\*bc"; b="\\"; c="*"; echo "<${a##$b"$c"}>"
Many shells share the bug where this prints <>, but of shells that do
not have this bug, while many print <bc> like what your patch makes dash
do, the most commonly used one, bash (as of version 4), does not: it
prints <\*bc>. I am not sure what exactly $b"$c" is trying to strip here.
Cheers,
Harald van Dijk
prev parent reply other threads:[~2024-04-27 13:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 11:02 [PATCH] expand: Fix naked backslah leakage Herbert Xu
2024-04-27 12:12 ` Harald van Dijk
2024-04-27 12:22 ` Herbert Xu
2024-04-27 13:46 ` Harald van Dijk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bf68a06-2050-4e5c-8e5e-3a703b21c9ee@gigawatt.nl \
--to=harald@gigawatt.nl \
--cc=dash@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).