From: Christoph Anton Mitterer <calestyo@scientia.org>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: dash@vger.kernel.org
Subject: Re: segfault with invalid shell script
Date: Mon, 21 Nov 2022 16:24:12 +0100 [thread overview]
Message-ID: <b03e330140ee8f8bd963ed7de0abb7cc55028797.camel@scientia.org> (raw)
In-Reply-To: <6af07303-357f-6274-6c16-df00835c7f6c@gigawatt.nl>
Hey Harald
On Mon, 2022-11-21 at 13:08 +0000, Harald van Dijk wrote:
>
> This is intentionally accepted, like all non-standard
> substitutions, during parsing, but is supposed to raise a
> substitution
> error at runtime, so that scripts can do
>
> if shell_supports_subst; then
> echo ${var//a/b}
> else
> echo $var | sed s/a/b/g
> fi
>
> Parsing this if statement requires parsing both sides of the branch,
> even ${var//a/b} will never be evaluated.
Well, while I can understand the merit of this... it may also have some
drawbacks.
> Actually performing this substitution should result in an error:
>
> $ dash -c 'echo ${$//1/2}'
> dash: 1: Bad substitution
It does here, too.
> What the intended behaviour here is though, is unclear. The
> substitution
> containing ${...//...} is evaluated but the ${...//...} is skipped
> because $restrict_path_list is unset.
In the original script, it may be set. I just shortened it.
> Fixing this so it produces "Bad substitution" should be easy, almost
> trivial.
I, personally, would like that anyway better.
Conditionally choosing the variant of shell command language during
runtime seems quite fragile.
I'd rather see straight away, that I use something non-supported.
Is there some bugtracker for dash, so that it doesn't get forgotten?
Thanks,
Chris.
next prev parent reply other threads:[~2022-11-21 15:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 2:38 segfault with invalid shell script Christoph Anton Mitterer
2022-11-21 13:08 ` Harald van Dijk
2022-11-21 15:24 ` Christoph Anton Mitterer [this message]
2022-11-21 22:25 ` Harald van Dijk
2022-11-22 13:59 ` Christoph Anton Mitterer
2022-11-23 2:20 ` Harald van Dijk
2022-11-23 4:04 ` Christoph Anton Mitterer
2022-11-23 10:54 ` Harald van Dijk
2022-11-23 17:21 ` Christoph Anton Mitterer
2022-11-23 23:30 ` Harald van Dijk
2022-11-24 5:18 ` Christoph Anton Mitterer
2022-12-06 5:56 ` [PATCH] parser: Add VSBIT to ensure subtype is never zero Herbert Xu
2022-12-06 15:19 ` Christoph Anton Mitterer
2022-12-07 4:03 ` Herbert Xu
2022-12-07 8:48 ` [v2 PATCH] " Herbert Xu
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=b03e330140ee8f8bd963ed7de0abb7cc55028797.camel@scientia.org \
--to=calestyo@scientia.org \
--cc=dash@vger.kernel.org \
--cc=harald@gigawatt.nl \
/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