--- src/bin/sh/parser.c 2005/11/06 11:44:02 1.6 +++ src/bin/sh/parser.c 2006/09/28 04:19:40 1.7 @@ -1189,7 +1189,8 @@ parsesub: { int bracketed_name = 0; /* used to handle ${[0-9]*} variables */ c = pgetc(); - if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) { + if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && + !is_special(c)) { USTPUTC('$', out); pungetc(); } else if (c == '(') { /* $(command) or $((arith)) */ @@ -1216,11 +1217,11 @@ parsesub: { else subtype = 0; } - if (is_name(c)) { + if (!is_eof(c) && is_name(c)) { do { STPUTC(c, out); c = pgetc(); - } while (is_in_name(c)); + } while (!is_eof(c) && is_in_name(c)); } else if (is_digit(c)) { if (bracketed_name) { do {