diff options
author | jilles <jilles@FreeBSD.org> | 2011-05-21 22:03:06 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-05-21 22:03:06 +0000 |
commit | 3dd8ae4222dacd974bc67c89db57fbe97d36ed79 (patch) | |
tree | 454723ef27b9a87e895c6adb1d91ac119ce9e994 /bin/sh/parser.c | |
parent | 0ebed84dd0d6e9f4219f1e24043618517c004c3e (diff) | |
download | FreeBSD-src-3dd8ae4222dacd974bc67c89db57fbe97d36ed79.zip FreeBSD-src-3dd8ae4222dacd974bc67c89db57fbe97d36ed79.tar.gz |
sh: Expand aliases after assignments and redirections.
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r-- | bin/sh/parser.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 192769b..151970b 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -619,6 +619,7 @@ simplecmd(union node **rpp, union node *redir) union node **orig_rpp = rpp; union node *n = NULL; int special; + int savecheckkwd; /* If we don't have any redirections already, then we must reset */ /* rpp to be the address of the local redir variable. */ @@ -634,7 +635,10 @@ simplecmd(union node **rpp, union node *redir) */ orig_rpp = rpp; + savecheckkwd = CHKALIAS; + for (;;) { + checkkwd = savecheckkwd; if (readtoken() == TWORD) { n = (union node *)stalloc(sizeof (struct narg)); n->type = NARG; @@ -642,6 +646,8 @@ simplecmd(union node **rpp, union node *redir) n->narg.backquote = backquotelist; *app = n; app = &n->narg.next; + if (savecheckkwd != 0 && !isassignment(wordtext)) + savecheckkwd = 0; } else if (lasttoken == TREDIR) { *rpp = n = redirnode; rpp = &n->nfile.next; @@ -1859,6 +1865,22 @@ goodname(const char *name) } +int +isassignment(const char *p) +{ + if (!is_name(*p)) + return 0; + p++; + for (;;) { + if (*p == '=') + return 1; + else if (!is_in_name(*p)) + return 0; + p++; + } +} + + /* * Called when an unexpected token is read during the parse. The argument * is the token that is expected, or -1 if more than one type of token can |