diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-07-20 18:23:39 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-07-20 18:23:39 +0000 |
commit | c3850c83d92ef1852f397c961c559c634756fb4a (patch) | |
tree | 1c7999365c4845a5be0b7593b9d367962ad25e1f /shell | |
parent | 27cbffddd86f1845249b25f30325c92f1b8bdfc1 (diff) | |
download | busybox-w32-c3850c83d92ef1852f397c961c559c634756fb4a.tar.gz busybox-w32-c3850c83d92ef1852f397c961c559c634756fb4a.tar.bz2 busybox-w32-c3850c83d92ef1852f397c961c559c634756fb4a.zip |
applying fix from:
0000152: ash: quoting rules for local variables different to globals
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 33 |
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 { | |||
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 | ||
1357 | static const struct builtincmd builtincmd[] = { | 1358 | static 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 | 3212 | static inline int | |
3213 | isassignment(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 | } |
@@ -9356,15 +9376,6 @@ static void setprompt(int); | |||
9356 | 9376 | ||
9357 | 9377 | ||
9358 | 9378 | ||
9359 | static inline int | ||
9360 | isassignment(const char *p) | ||
9361 | { | ||
9362 | const char *q = endofname(p); | ||
9363 | if (p == q) | ||
9364 | return 0; | ||
9365 | return *q == '='; | ||
9366 | } | ||
9367 | |||
9368 | 9379 | ||
9369 | /* | 9380 | /* |
9370 | * Read and parse a command. Returns NEOF on end of file. (NULL is a | 9381 | * Read and parse a command. Returns NEOF on end of file. (NULL is a |