about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/parameter.c2
-rw-r--r--Src/Zle/zle_main.c3
-rw-r--r--Src/builtin.c6
-rw-r--r--Src/exec.c2
-rw-r--r--Src/hist.c2
-rw-r--r--Src/input.c14
-rw-r--r--Src/params.c10
7 files changed, 31 insertions, 8 deletions
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index e023ca9fe..5b897a7dc 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -181,6 +181,8 @@ scanpmparameters(HashTable ht, ScanFunc func, int flags)
 
     for (i = 0; i < realparamtab->hsize; i++)
 	for (hn = realparamtab->nodes[i]; hn; hn = hn->next) {
+	    if (((Param)hn)->flags & PM_UNSET)
+		continue;
 	    pm.nam = hn->nam;
 	    if (func != scancountparams &&
 		((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index cb1854e9b..b7c7767b7 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -949,9 +949,10 @@ bin_vared(char *name, char **args, char *ops, int func)
 
 	/*
 	 * Use spacesplit with fourth argument 1: identify quoted separators,
-	 * unquote but don't split.
+	 * and unquote.  This duplicates the string, so we still need to free.
 	 */
 	a = spacesplit(t, 1, 0, 1);
+	zsfree(t);
 	if (PM_TYPE(pm->flags) == PM_ARRAY)
 	    setaparam(args[0], a);
 	else
diff --git a/Src/builtin.c b/Src/builtin.c
index bfb2f85b8..be5d124b6 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2399,8 +2399,10 @@ bin_unset(char *name, char **argv, char *ops, int func)
 		zerrnam(name, "%s: invalid element for unset", s, 0);
 		returnval = 1;
 	    }
-	} else
-	    unsetparam_pm(pm, 0, 1);
+	} else {
+	    if (unsetparam_pm(pm, 0, 1))
+		returnval = 1;
+	}
 	if (ss)
 	    *ss = '[';
     }
diff --git a/Src/exec.c b/Src/exec.c
index 77b657c18..7a457696a 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3272,7 +3272,7 @@ loadautofn(Shfunc shf, int fksh, int autol)
 	return NULL;
     }
     if (!prog)
-	prog = &dummy_eprog;
+	return NULL;
     if (ksh == 2 || (ksh == 1 && isset(KSHAUTOLOAD))) {
 	if (autol) {
 	    prog->flags |= EF_RUN;
diff --git a/Src/hist.c b/Src/hist.c
index e40007049..4a01ff652 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -290,6 +290,8 @@ safeinungetc(int c)
 void
 herrflush(void)
 {
+    inpopalias();
+
     while (!lexstop && inbufct && !strin)
 	hwaddc(ingetc());
 }
diff --git a/Src/input.c b/Src/input.c
index 525a3202a..bf31c09cf 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -540,3 +540,17 @@ inpop(void)
 	inpoptop();
     } while (remcont);
 }
+
+/*
+ * Expunge any aliases from the input stack; they shouldn't appear
+ * in the history and need to be flushed explicitly when we encounter
+ * an error.
+ */
+
+/**/
+void
+inpopalias(void)
+{
+    while (inbufflags & INP_ALIAS)
+	inpoptop();
+}
diff --git a/Src/params.c b/Src/params.c
index aa80bcc78..e2a9f61f7 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2089,18 +2089,18 @@ unsetparam(char *s)
 /* Unset a parameter */
 
 /**/
-mod_export void
+mod_export int
 unsetparam_pm(Param pm, int altflag, int exp)
 {
     Param oldpm, altpm;
 
     if ((pm->flags & PM_READONLY) && pm->level <= locallevel) {
 	zerr("read-only variable: %s", pm->nam, 0);
-	return;
+	return 1;
     }
     if ((pm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
 	zerr("%s: restricted", pm->nam, 0);
-	return;
+	return 1;
     }
     pm->unsetfn(pm, exp);
     if ((pm->flags & PM_EXPORTED) && pm->env) {
@@ -2142,7 +2142,7 @@ unsetparam_pm(Param pm, int altflag, int exp)
      */
     if ((pm->level && locallevel >= pm->level) ||
 	(pm->flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL)
-	return;
+	return 0;
 
     /* remove parameter node from table */
     paramtab->removenode(paramtab, pm->nam);
@@ -2167,6 +2167,8 @@ unsetparam_pm(Param pm, int altflag, int exp)
     }
 
     paramtab->freenode((HashNode) pm); /* free parameter node */
+
+    return 0;
 }
 
 /* Standard function to unset a parameter.  This is mostly delegated to *