[klibc] [klibc:update-dash] [EXPAND] Propagate EXP_QPAT in subevalvar
klibc-bot for Herbert Xu
herbert at gondor.apana.org.au
Thu Jan 24 19:15:07 PST 2019
Commit-ID: 6fdcdeda572daa647e508fa3bbf972a8c5f73e02
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=6fdcdeda572daa647e508fa3bbf972a8c5f73e02
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Fri, 23 Aug 2013 20:04:12 +1000
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000
[klibc] [EXPAND] Propagate EXP_QPAT in subevalvar
On Tue, Aug 28, 2012 at 01:27:24PM +0000, Todor Vlaev wrote:
>
> While playing around with parameter expansion I noticed that the
> following didn't work in dash (dash 0.5.5.1-7.4ubuntu1) as compared
> to bash even though I believe it should be POSIX-compliant:
>
> my_str=swan; last_char="${my_str#${my_str%?}}"; echo ${last_char}
>
> If the double quotes are removed, the last character is printed correctly.
>
> At a quick glance through the commits after the 0.5.5.1 release I saw
> the following bug fix. Could it be related?
>
> 0d7d66039b614b642c775432fd64aa8c11f9a64d
> [EXPAND] Fix quoted pattern patch breakage
We need to propagate EXP_QPAT in subevalvar as otherwise a nested
parameter expansion within subevalvar may be expanded incorrectly.
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/expand.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/usr/dash/expand.c b/usr/dash/expand.c
index 355e924e..c4d52606 100644
--- a/usr/dash/expand.c
+++ b/usr/dash/expand.c
@@ -650,7 +650,8 @@ subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varfla
char *(*scan)(char *, char *, char *, char *, int , int);
argstr(p, EXP_TILDE | (subtype != VSASSIGN && subtype != VSQUESTION ?
- (flag & EXP_QUOTED ? EXP_QPAT : EXP_CASE) : 0));
+ (flag & (EXP_QUOTED | EXP_QPAT) ?
+ EXP_QPAT : EXP_CASE) : 0));
STPUTC('\0', expdest);
argbackq = saveargbackq;
startp = stackblock() + startloc;
More information about the klibc
mailing list