Re: [bug #67358] Extra space in parameter expansion with quoted strings
From:
microsuxx
Subject:
Re: [bug #67358] Extra space in parameter expansion with quoted strings and trailing $.
Date:
Mon, 28 Jul 2025 18:03:51 +0200
++
On Mon, Jul 28, 2025, 4:52 PM Chet Ramey <chet.ramey@case.edu> wrote:
> On 7/28/25 4:29 AM, Oğuz wrote:
> > On Sat, Jul 26, 2025 at 9:44 PM Greg Wooledge <greg@wooledge.org> wrote:
> >> The quotation marks don't appear to matter, but
> >> the trailing $ does.
> >
> > `$!' works as well, when there's no most recent asynchronous job:
> >
> > $ printf '<%s>\n' $(seq 3)$!
> > <1
> > 2
> > 3>
> > $
> >
> > I think the problem is right here:
> >
>https://cgit.git.savannah.gnu.org/cgit/bash.git/tree/subst.c?h=devel#n11524
> > The function `param_expand' writes 0 to `*expanded_something' when
> > `string' ends with `$' or `$!' and there's no async job, and bash
> > forgets all the expansions it has done in that word. Maybe it was
> > supposed to be called with the address of a local copy of
> > `expanded_something'? There's a variable named `local_expanded' in
> > that function that seems to be unused...
>
> Good catch, that is the right approach.
>
> Chet
> --
> ``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/
>