Re: Expansion-lookalikes in heredoc delimiters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote:
>
> It's perfectly consistent. It gets accepted at parse time, it only gets
> rejected at expansion time. That's how dash generally behaves as well:
> 
>   $ dash -c 'echo ${x^}'
>   dash: 1: Bad substitution
>   $ dash -c ': || echo ${x^}'
>   $
> 
> Historically, as I understand it, ash would reject both of these, but you
> specifically modified dash to accept invalid expansions during parsing
> (which makes sense):
> 
> 
> <https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=3df3edd13389ae768010bfacee5612346b413e38>
> 
> >In any case, this substituion is invalid in all of these shells so
> >does it really matter?
> 
> Okay, it can be trivially modified to something that does work in other
> shells (even if it were actually executed), but gets rejected at parse time
> by dash:
> 
>   if false; then
>     : ${$+
>   }
>   fi

That's just a bug in dash's parser with ${} in general, because
it bombs out without the if clause too:

	: ${$+
	}

> It'd be nice if all shells used the same parse rules, so that scripts can
> detect dynamically which expansions are supported, but don't have to go
> through ugly eval commands to use them.

I think the reason dash bombs out on your first example (fi) isn't
because of the keyword at all, but it's actually the same reason
as the second, namely newlines are not accepted within parameter
substitution.  If we fixed this then it should work correctly.

Cheers,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux