From 0c8da1c3b558f9827d593d92a726f582642d3279 Mon Sep 17 00:00:00 2001 From: "Federico G. Schwindt" Date: Wed, 24 Mar 2010 08:27:27 +0000 Subject: fix the cases where ${name#pat} and ${name%pat} will generate an empty word when they shouldn't. originally from mksh but modified to handle the case when the expr is quoted as noticed by halex@. input from guenther@ and halex@, millert@ ok --- bin/ksh/eval.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c index e9b88066a22..1918751c677 100644 --- a/bin/ksh/eval.c +++ b/bin/ksh/eval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eval.c,v 1.34 2009/01/29 23:27:26 jaredy Exp $ */ +/* $OpenBSD: eval.c,v 1.35 2010/03/24 08:27:26 fgsch Exp $ */ /* * Expansion - quoting, separation, substitution, globbing @@ -375,7 +375,10 @@ expand(char *cp, /* input word */ */ x.str = trimsub(str_val(st->var), dp, st->stype); - type = XSUB; + if (x.str[0] != '\0' || st->quote) + type = XSUB; + else + type = XNULLSUB; if (f&DOBLANK) doblank++; st = st->prev; -- cgit v1.2.3