DASH Shell discussions
 help / color / mirror / Atom feed
* Failure of nested substring processing inside double-quotes
@ 2014-10-06 20:03 Paul Smith
  2014-10-08  2:28 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Smith @ 2014-10-06 20:03 UTC (permalink / raw)
  To: dash

Hi all.  I recently found a bug in dash's handling of substring
processing, when the variable is contained within quotes.

In bash, this works:

  bash$ echo $PWD
  /home/psmith

  bash$ echo ${PWD%${PWD##*/}}.
  /home/.

  bash$ echo "${PWD%${PWD##*/}}."
  /home/.

which is what I expect.  However, in dash we get:

  dash$ echo $PWD
  /home/psmith

  dash$ echo ${PWD%${PWD##*/}}.
  /home/.

  dash$ echo "${PWD%${PWD##*/}}."
  .

Whoops!  Inside double-quotes dash is mishandling the nested string
substitution.  If I break it up into two steps it works OK, regardless
of whether or not it's quoted.

This is dash 0.5.7-4ubuntu1 (from Ubuntu GNOME 14.04).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Failure of nested substring processing inside double-quotes
  2014-10-06 20:03 Failure of nested substring processing inside double-quotes Paul Smith
@ 2014-10-08  2:28 ` Herbert Xu
  2014-10-08  5:08   ` Paul Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2014-10-08  2:28 UTC (permalink / raw)
  To: Paul Smith; +Cc: dash

On Mon, Oct 06, 2014 at 08:03:13PM +0000, Paul Smith wrote:
> Hi all.  I recently found a bug in dash's handling of substring
> processing, when the variable is contained within quotes.
> 
> In bash, this works:
> 
>   bash$ echo $PWD
>   /home/psmith
> 
>   bash$ echo ${PWD%${PWD##*/}}.
>   /home/.
> 
>   bash$ echo "${PWD%${PWD##*/}}."
>   /home/.
> 
> which is what I expect.  However, in dash we get:
> 
>   dash$ echo $PWD
>   /home/psmith
> 
>   dash$ echo ${PWD%${PWD##*/}}.
>   /home/.
> 
>   dash$ echo "${PWD%${PWD##*/}}."
>   .
> 
> Whoops!  Inside double-quotes dash is mishandling the nested string
> substitution.  If I break it up into two steps it works OK, regardless
> of whether or not it's quoted.
> 
> This is dash 0.5.7-4ubuntu1 (from Ubuntu GNOME 14.04).

This is already fixed in the current git tree, by the commit:

commit a7c21a6f4cb42d967854cae954efd4ee66bdea9c
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Fri Aug 23 20:04:12 2013 +1000

    [EXPAND] Propagate EXP_QPAT in subevalvar

So please report this to Ubuntu.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Failure of nested substring processing inside double-quotes
  2014-10-08  2:28 ` Herbert Xu
@ 2014-10-08  5:08   ` Paul Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Smith @ 2014-10-08  5:08 UTC (permalink / raw)
  To: Herbert Xu; +Cc: dash

On Wed, 2014-10-08 at 10:28 +0800, Herbert Xu wrote:
> This is already fixed in the current git tree, by the commit:

Thanks Herbert!  I should have checked Git.  I did check Debian and the
current dash in "stable" and "sid" all still have this issue.

The version in "experimental", however, dash_0.5.8-1_amd64.deb, has the
fix in it and works.

I'll report it in the appropriate places.

Cheers!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-08  5:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-06 20:03 Failure of nested substring processing inside double-quotes Paul Smith
2014-10-08  2:28 ` Herbert Xu
2014-10-08  5:08   ` Paul Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox