Failure of nested substring processing inside double-quotes
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).
Quoted 25 lines · Paul Smith
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/psmithbash$ echo ${PWD%${PWD##*/}}. /home/. bash$ echo "${PWD%${PWD##*/}}." /home/.which is what I expect. However, in dash we get:
dash$ echo $PWD
/home/psmithdash$ echo ${PWD%${PWD##*/}}. /home/. dash$ echo "${PWD%${PWD##*/}}." .
Quoted 5 lines
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 <[email protected]> Date: Fri Aug 23 20:04:12 2013 +1000
[EXPAND] Propagate EXP_QPAT in subevalvar
So please report this to Ubuntu.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 1 line · Herbert Xu
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!