diff options
author | Ron Yorston <rmy@pobox.com> | 2018-04-12 19:38:22 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-04-12 19:38:22 +0100 |
commit | 493058551b07dd88aa79facbded8b8388aa41a75 (patch) | |
tree | a08d57d54668d7f6e63f54737e4fad4f38058ea5 | |
parent | 0038f9d39a306c3c7860756f03102de217dc5cd9 (diff) | |
download | busybox-w32-493058551b07dd88aa79facbded8b8388aa41a75.tar.gz busybox-w32-493058551b07dd88aa79facbded8b8388aa41a75.tar.bz2 busybox-w32-493058551b07dd88aa79facbded8b8388aa41a75.zip |
ash: make commandname a global variable
commandname is static so isn't copied during forkshell. This was
causing the arith-tests script in the shell test suite to fail
because without commandname some error reports were missing line
numbers.
-rw-r--r-- | shell/ash.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index 208fce538..3e3193eba 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -443,6 +443,7 @@ struct globals_misc { | |||
443 | char *physdir; // = nullstr; /* physical working directory */ | 443 | char *physdir; // = nullstr; /* physical working directory */ |
444 | 444 | ||
445 | char *arg0; /* value of $0 */ | 445 | char *arg0; /* value of $0 */ |
446 | char *commandname; | ||
446 | 447 | ||
447 | struct jmploc *exception_handler; | 448 | struct jmploc *exception_handler; |
448 | 449 | ||
@@ -525,6 +526,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc; | |||
525 | #define curdir (G_misc.curdir ) | 526 | #define curdir (G_misc.curdir ) |
526 | #define physdir (G_misc.physdir ) | 527 | #define physdir (G_misc.physdir ) |
527 | #define arg0 (G_misc.arg0 ) | 528 | #define arg0 (G_misc.arg0 ) |
529 | #define commandname (G_misc.commandname) | ||
528 | #define exception_handler (G_misc.exception_handler) | 530 | #define exception_handler (G_misc.exception_handler) |
529 | #define exception_type (G_misc.exception_type ) | 531 | #define exception_type (G_misc.exception_type ) |
530 | #define suppress_int (G_misc.suppress_int ) | 532 | #define suppress_int (G_misc.suppress_int ) |
@@ -1397,7 +1399,6 @@ struct parsefile { | |||
1397 | 1399 | ||
1398 | static struct parsefile basepf; /* top level input file */ | 1400 | static struct parsefile basepf; /* top level input file */ |
1399 | static struct parsefile *g_parsefile = &basepf; /* current input file */ | 1401 | static struct parsefile *g_parsefile = &basepf; /* current input file */ |
1400 | static char *commandname; /* currently executing command */ | ||
1401 | 1402 | ||
1402 | 1403 | ||
1403 | /* ============ Message printing */ | 1404 | /* ============ Message printing */ |
@@ -15329,6 +15330,7 @@ globals_var_copy(struct globals_var *gvp) | |||
15329 | #undef curdir | 15330 | #undef curdir |
15330 | #undef physdir | 15331 | #undef physdir |
15331 | #undef arg0 | 15332 | #undef arg0 |
15333 | #undef commandname | ||
15332 | #undef nullstr | 15334 | #undef nullstr |
15333 | static int | 15335 | static int |
15334 | globals_misc_size(int funcblocksize, struct globals_misc *p) | 15336 | globals_misc_size(int funcblocksize, struct globals_misc *p) |
@@ -15340,7 +15342,8 @@ globals_misc_size(int funcblocksize, struct globals_misc *p) | |||
15340 | if (p->physdir != p->nullstr) | 15342 | if (p->physdir != p->nullstr) |
15341 | funcblocksize += align_len(p->physdir); | 15343 | funcblocksize += align_len(p->physdir); |
15342 | funcblocksize += align_len(p->arg0); | 15344 | funcblocksize += align_len(p->arg0); |
15343 | nodeptrcount += 4; /* minusc, curdir, physdir, arg0 */ | 15345 | funcblocksize += align_len(p->commandname); |
15346 | nodeptrcount += 5; /* minusc, curdir, physdir, arg0, commandname */ | ||
15344 | return funcblocksize; | 15347 | return funcblocksize; |
15345 | } | 15348 | } |
15346 | 15349 | ||
@@ -15356,7 +15359,9 @@ globals_misc_copy(struct globals_misc *p) | |||
15356 | new->curdir = p->curdir != p->nullstr ? nodeckstrdup(p->curdir) : new->nullstr; | 15359 | new->curdir = p->curdir != p->nullstr ? nodeckstrdup(p->curdir) : new->nullstr; |
15357 | new->physdir = p->physdir != p->nullstr ? nodeckstrdup(p->physdir) : new->nullstr; | 15360 | new->physdir = p->physdir != p->nullstr ? nodeckstrdup(p->physdir) : new->nullstr; |
15358 | new->arg0 = nodeckstrdup(p->arg0); | 15361 | new->arg0 = nodeckstrdup(p->arg0); |
15362 | new->commandname = nodeckstrdup(p->commandname); | ||
15359 | SAVE_PTR4(new->minusc, new->curdir, new->physdir, new->arg0); | 15363 | SAVE_PTR4(new->minusc, new->curdir, new->physdir, new->arg0); |
15364 | SAVE_PTR(new->commandname); | ||
15360 | return new; | 15365 | return new; |
15361 | } | 15366 | } |
15362 | 15367 | ||