aboutsummaryrefslogtreecommitdiff
path: root/busybox/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'busybox/shell/ash.c')
-rw-r--r--busybox/shell/ash.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/busybox/shell/ash.c b/busybox/shell/ash.c
index d9ea2b0f3..f16edbc38 100644
--- a/busybox/shell/ash.c
+++ b/busybox/shell/ash.c
@@ -1353,6 +1353,7 @@ struct builtincmd {
1353 1353
1354#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1) 1354#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
1355#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2) 1355#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
1356#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
1356 1357
1357static const struct builtincmd builtincmd[] = { 1358static const struct builtincmd builtincmd[] = {
1358 { BUILTIN_SPEC_REG ".", dotcmd }, 1359 { BUILTIN_SPEC_REG ".", dotcmd },
@@ -3208,7 +3209,14 @@ parse_command_args(char **argv, const char **path)
3208} 3209}
3209#endif 3210#endif
3210 3211
3211 3212static inline int
3213isassignment(const char *p)
3214{
3215 const char *q = endofname(p);
3216 if (p == q)
3217 return 0;
3218 return *q == '=';
3219}
3212 3220
3213/* 3221/*
3214 * Execute a simple command. 3222 * Execute a simple command.
@@ -3232,6 +3240,8 @@ evalcommand(union node *cmd, int flags)
3232 int cmd_is_exec; 3240 int cmd_is_exec;
3233 int status; 3241 int status;
3234 char **nargv; 3242 char **nargv;
3243 struct builtincmd *bcmd;
3244 int pseudovarflag = 0;
3235 3245
3236 /* First expand the arguments. */ 3246 /* First expand the arguments. */
3237 TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags)); 3247 TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@@ -3246,11 +3256,21 @@ evalcommand(union node *cmd, int flags)
3246 *arglist.lastp = NULL; 3256 *arglist.lastp = NULL;
3247 3257
3248 argc = 0; 3258 argc = 0;
3259 if (cmd->ncmd.args)
3260 {
3261 bcmd = find_builtin(cmd->ncmd.args->narg.text);
3262 pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
3263 }
3264
3249 for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) { 3265 for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
3250 struct strlist **spp; 3266 struct strlist **spp;
3251 3267
3252 spp = arglist.lastp; 3268 spp = arglist.lastp;
3253 expandarg(argp, &arglist, EXP_FULL | EXP_TILDE); 3269 if (pseudovarflag && isassignment(argp->narg.text))
3270 expandarg(argp, &arglist, EXP_VARTILDE);
3271 else
3272 expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
3273
3254 for (sp = *spp; sp; sp = sp->next) 3274 for (sp = *spp; sp; sp = sp->next)
3255 argc++; 3275 argc++;
3256 } 3276 }
@@ -9370,15 +9390,6 @@ static void setprompt(int);
9370 9390
9371 9391
9372 9392
9373static inline int
9374isassignment(const char *p)
9375{
9376 const char *q = endofname(p);
9377 if (p == q)
9378 return 0;
9379 return *q == '=';
9380}
9381
9382 9393
9383/* 9394/*
9384 * Read and parse a command. Returns NEOF on end of file. (NULL is a 9395 * Read and parse a command. Returns NEOF on end of file. (NULL is a
@@ -12005,7 +12016,7 @@ setvar(const char *name, const char *val, int flags)
12005 INTOFF; 12016 INTOFF;
12006 p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen); 12017 p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
12007 *p++ = '\0'; 12018 *p++ = '\0';
12008 if (vallen) { 12019 if (val) {
12009 p[-1] = '='; 12020 p[-1] = '=';
12010 p = mempcpy(p, val, vallen); 12021 p = mempcpy(p, val, vallen);
12011 } 12022 }