Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260701201925.GB3520958@port70.net>
Date: Wed, 1 Jul 2026 22:19:25 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: Rich Felker <dalias@...c.org>, musl@...ts.openwall.com
Subject: Re: [PATCH 0/4] wordexp fixes

* Szabolcs Nagy <nsz@...t70.net> [2026-06-30 23:29:08 +0200]:
> * Rich Felker <dalias@...c.org> [2026-06-30 15:53:33 -0400]:
> > On Tue, Jun 30, 2026 at 04:31:33PM +0200, Szabolcs Nagy wrote:
> > >   wordexp("$(echo x $U) y", p, WRDE_UNDEF|WRDE_SHOWERR)
> > > 
> > > was "x","y", now "y" and prints an error about U. the echo is not
> > > executed, but wordexp succeeds. undef failure is not propagated from
> > > a command substitution (but it inherits -u).
> > 
> > I think this is contrary to the behavior as specified. The $U here is
> > not an expansion by the wordexp, but an expansion in the command
> > inside $(), which is not specified to be subject to set -u. However it
> > is somewhat ambiguous.
> > 
> > But as you've noted, if the WRDE_UNDEF should affect things inside
> > $(), it's still wrong because wordexp isn't failing.
> > 
> > I think it's clear that the behavior should be either success or an
> > error from wordexp, not just a silent error from the $().
> 
> one option is to only handle WRDE_NOCMD|WRDE_UNDEF
> (otherwise fail with syntax?)

or we can try to replace $( with $(set +u; like

 "$(set +u;echo x $U) y"

this returns "x","y" and does not print errors with -u.

the current nocmd parser can reliably detect the start
of $( and `, but cant get to the matching ),`, to find
all occurances. for that i think the parser needs to
handle pipelines, case/esac, here-doc,..

> 
> or we can try sh -u with monitored fd 2 and assume
> any write to fd 2 is either syntax or undef error.
> this would catch subshell errors, but also user code
> printing to stderr...

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.