aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2005-07-20 18:23:39 +0000
committerPaul Fox <pgf@brightstareng.com>2005-07-20 18:23:39 +0000
commitc3850c83d92ef1852f397c961c559c634756fb4a (patch)
tree1c7999365c4845a5be0b7593b9d367962ad25e1f /shell
parent27cbffddd86f1845249b25f30325c92f1b8bdfc1 (diff)
downloadbusybox-c3850c83d92ef1852f397c961c559c634756fb4a.tar.gz
applying fix from:
0000152: ash: quoting rules for local variables different to globals
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 57316c916..045d659ed 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1353,6 +1353,7 @@ struct builtincmd {
#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
+#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
static const struct builtincmd builtincmd[] = {
{ BUILTIN_SPEC_REG ".", dotcmd },
@@ -3208,7 +3209,14 @@ parse_command_args(char **argv, const char **path)
}
#endif
-
+static inline int
+isassignment(const char *p)
+{
+ const char *q = endofname(p);
+ if (p == q)
+ return 0;
+ return *q == '=';
+}
/*
* Execute a simple command.
@@ -3232,6 +3240,8 @@ evalcommand(union node *cmd, int flags)
int cmd_is_exec;
int status;
char **nargv;
+ struct builtincmd *bcmd;
+ int pseudovarflag = 0;
/* First expand the arguments. */
TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@@ -3246,11 +3256,21 @@ evalcommand(union node *cmd, int flags)
*arglist.lastp = NULL;
argc = 0;
+ if (cmd->ncmd.args)
+ {
+ bcmd = find_builtin(cmd->ncmd.args->narg.text);
+ pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
+ }
+
for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
struct strlist **spp;
spp = arglist.lastp;
- expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+ if (pseudovarflag && isassignment(argp->narg.text))
+ expandarg(argp, &arglist, EXP_VARTILDE);
+ else
+ expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+
for (sp = *spp; sp; sp = sp->next)
argc++;
}
@@ -9356,15 +9376,6 @@ static void setprompt(int);
-static inline int
-isassignment(const char *p)
-{
- const char *q = endofname(p);
- if (p == q)
- return 0;
- return *q == '=';
-}
-
/*
* Read and parse a command. Returns NEOF on end of file. (NULL is a