From 802ae96cf9c7cd97654c86ad9bcbb02be9785e0e Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Mon, 10 Apr 2000 09:18:26 +0000 Subject: properly restore scriptname in doshfunc() (10620) --- ChangeLog | 2 ++ Src/exec.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5692bb58d..3e2df6ac4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2000-04-10 Sven Wischnowsky + * 10620: Src/exec.c: properly restore scriptname in doshfunc() + * users/3019: Completion/Core/_path_files: use special-dirs with _path_files -g diff --git a/Src/exec.c b/Src/exec.c index d06821e76..bc9edce2c 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3249,7 +3249,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) { char **tab, **x, *oargv0; int oldzoptind, oldlastval, oldoptcind; - char saveopts[OPT_SIZE], *oldscriptname = NULL, *fname = dupstring(name); + char saveopts[OPT_SIZE], *oldscriptname = scriptname, *fname = dupstring(name); int obreaks; struct funcstack fstack; #ifdef MAX_FUNCTION_DEPTH @@ -3267,10 +3267,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) starttrapscope(); tab = pparams; - if (!(flags & PM_UNDEFINED)) { - oldscriptname = scriptname; + if (!(flags & PM_UNDEFINED)) scriptname = dupstring(name); - } oldzoptind = zoptind; zoptind = 1; oldoptcind = optcind; @@ -3308,6 +3306,8 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) if(++funcdepth > MAX_FUNCTION_DEPTH) { zerr("maximum nested function level reached", NULL, 0); + scriptname = oldscriptname; + popheap(); return; } #endif @@ -3328,6 +3328,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) if (!noreturnval) lastval = 1; popheap(); + scriptname = oldscriptname; return; } prog = shf->funcdef; @@ -3349,8 +3350,7 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) pparams = tab; optcind = oldoptcind; zoptind = oldzoptind; - if (oldscriptname) - scriptname = oldscriptname; + scriptname = oldscriptname; if (isset(LOCALOPTIONS)) { /* restore all shell options except PRIVILEGED and RESTRICTED */ -- cgit 1.4.1