diff --git a/eval.c b/eval.c index 98342bb..5e0da79 100644 --- a/eval.c +++ b/eval.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.32 2007/07/06 02:22:56 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.33 2007/07/06 02:39:36 tg Exp $"); #ifdef MKSH_SMALL #define MKSH_NOPWNAM @@ -798,7 +798,7 @@ varsub(Expand *xp, const char *sp, const char *word, stype = 0x80; c = word[slen + 0] == CHAR ? word[slen + 1] : 0; } - if (stype == 0x80 && !c && word[slen] && word[slen] != CHAR) { + if (stype == 0x80 && (c == ' ' || c == '0')) { stype |= '0'; } else if (ctype(c, C_SUBOP1)) { slen += 2; diff --git a/lex.c b/lex.c index bde9cb4..372a289 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.41 2007/07/06 02:24:18 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.42 2007/07/06 02:39:37 tg Exp $"); /* Structure to keep track of the lexing state and the various pieces of info * needed for each particular state. */ @@ -291,7 +291,7 @@ yylex(int cf) *wp++ = CHAR, *wp++ = c; c = getsc(); if (c == ':') { - *wp++ = QCHAR; + *wp++ = CHAR; *wp++ = '0'; *wp++ = ADELIM; *wp++ = ':'; @@ -303,8 +303,11 @@ yylex(int cf) c == '('/*)*/ || c == ' ' || c == '$' /* XXX what else? */) { /* substring subst. */ - *wp++ = QCHAR; - *wp++ = c; + if (c != ' ') { + *wp++ = CHAR; + *wp++ = ' '; + } + ungetsc(c); PUSH_STATE(SADELIM); statep->ls_sadelim.delimiter = ':'; statep->ls_sadelim.num = 2;