summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2010-03-24 08:27:27 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2010-03-24 08:27:27 +0000
commit0c8da1c3b558f9827d593d92a726f582642d3279 (patch)
treeed72007c9ff21dbb6ae4ed65f6c52eeef8aa4836
parente7fd1f470c39e018961156e542aec0115a770e93 (diff)
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
-rw-r--r--bin/ksh/eval.c7
1 files 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;