diff options
Diffstat (limited to 'busybox/shell')
-rw-r--r-- | busybox/shell/ash.c | 35 | ||||
-rw-r--r-- | busybox/shell/cmdedit.c | 4 | ||||
-rw-r--r-- | busybox/shell/msh.c | 2 |
3 files changed, 26 insertions, 15 deletions
diff --git a/busybox/shell/ash.c b/busybox/shell/ash.c index d9ea2b0..f16edbc 100644 --- a/busybox/shell/ash.c +++ b/busybox/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++; } @@ -9370,15 +9390,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 @@ -12005,7 +12016,7 @@ setvar(const char *name, const char *val, int flags) INTOFF; p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen); *p++ = '\0'; - if (vallen) { + if (val) { p[-1] = '='; p = mempcpy(p, val, vallen); } diff --git a/busybox/shell/cmdedit.c b/busybox/shell/cmdedit.c index 56b789a..3380dff 100644 --- a/busybox/shell/cmdedit.c +++ b/busybox/shell/cmdedit.c @@ -782,8 +782,8 @@ static int match_compare(const void *a, const void *b) #define QUOT (UCHAR_MAX+1) #define collapse_pos(is, in) { \ - memcpy(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \ - memcpy(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); } + memmove(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \ + memmove(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); } static int find_match(char *matchBuf, int *len_with_quotes) { diff --git a/busybox/shell/msh.c b/busybox/shell/msh.c index 2fb0df7..14e8758 100644 --- a/busybox/shell/msh.c +++ b/busybox/shell/msh.c @@ -4290,7 +4290,7 @@ int quoted; } var_name[var_index++] = *src++; - while (isalnum(*src)) + while (isalnum(*src) || *src=='_') var_name[var_index++] = *src++; var_name[var_index] = 0; |