diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2011-05-21 22:03:06 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2011-05-21 22:03:06 +0000 |
commit | 05a447d0b9b86ef8de263ef18da269f2c1e57f88 (patch) | |
tree | 454723ef27b9a87e895c6adb1d91ac119ce9e994 /bin/sh/parser.c | |
parent | aa27d9ef943344b9cbbb7746b224b307c35d7a3e (diff) | |
download | src-05a447d0b9b86ef8de263ef18da269f2c1e57f88.tar.gz src-05a447d0b9b86ef8de263ef18da269f2c1e57f88.zip |
sh: Expand aliases after assignments and redirections.
Notes
Notes:
svn path=/head/; revision=222165
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 192769b076c4..151970b79d08 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 |