From 493058551b07dd88aa79facbded8b8388aa41a75 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 12 Apr 2018 19:38:22 +0100 Subject: 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. --- shell/ash.c | 9 +++++++-- 1 file 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 { char *physdir; // = nullstr; /* physical working directory */ char *arg0; /* value of $0 */ + char *commandname; struct jmploc *exception_handler; @@ -525,6 +526,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc; #define curdir (G_misc.curdir ) #define physdir (G_misc.physdir ) #define arg0 (G_misc.arg0 ) +#define commandname (G_misc.commandname) #define exception_handler (G_misc.exception_handler) #define exception_type (G_misc.exception_type ) #define suppress_int (G_misc.suppress_int ) @@ -1397,7 +1399,6 @@ struct parsefile { static struct parsefile basepf; /* top level input file */ static struct parsefile *g_parsefile = &basepf; /* current input file */ -static char *commandname; /* currently executing command */ /* ============ Message printing */ @@ -15329,6 +15330,7 @@ globals_var_copy(struct globals_var *gvp) #undef curdir #undef physdir #undef arg0 +#undef commandname #undef nullstr static int globals_misc_size(int funcblocksize, struct globals_misc *p) @@ -15340,7 +15342,8 @@ globals_misc_size(int funcblocksize, struct globals_misc *p) if (p->physdir != p->nullstr) funcblocksize += align_len(p->physdir); funcblocksize += align_len(p->arg0); - nodeptrcount += 4; /* minusc, curdir, physdir, arg0 */ + funcblocksize += align_len(p->commandname); + nodeptrcount += 5; /* minusc, curdir, physdir, arg0, commandname */ return funcblocksize; } @@ -15356,7 +15359,9 @@ globals_misc_copy(struct globals_misc *p) new->curdir = p->curdir != p->nullstr ? nodeckstrdup(p->curdir) : new->nullstr; new->physdir = p->physdir != p->nullstr ? nodeckstrdup(p->physdir) : new->nullstr; new->arg0 = nodeckstrdup(p->arg0); + new->commandname = nodeckstrdup(p->commandname); SAVE_PTR4(new->minusc, new->curdir, new->physdir, new->arg0); + SAVE_PTR(new->commandname); return new; } -- cgit v1.2.3-55-g6feb