aboutsummaryrefslogtreecommitdiff
path: root/bin/sh/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r--bin/sh/parser.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index f92f5644e0fa..d40d28a072da 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -1192,7 +1192,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)) */
@@ -1219,11 +1220,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 {