about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorMartijn Dekker <martijn@inlv.org>2017-10-11 20:44:54 +0200
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2017-11-02 20:03:45 +0000
commitbf04ffb54286c44deef6e4ceb6445d6af30897f9 (patch)
treef73121d9f67f881312d8234a5277e550063e5918 /Src/builtin.c
parent2273fe478a750fbe0ec368933513de7e22e7761a (diff)
downloadzsh-bf04ffb54286c44deef6e4ceb6445d6af30897f9.tar.gz
zsh-bf04ffb54286c44deef6e4ceb6445d6af30897f9.tar.xz
zsh-bf04ffb54286c44deef6e4ceb6445d6af30897f9.zip
41866: No error unsetting nonexistent function for POSIXBUILTINS
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 84a2beee0..0ff9e4f16 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -125,7 +125,7 @@ static struct builtin builtins[] =
     BUILTIN("unalias", 0, bin_unhash, 0, -1, BIN_UNALIAS, "ams", NULL),
     BUILTIN("unfunction", 0, bin_unhash, 1, -1, BIN_UNFUNCTION, "m", "f"),
     BUILTIN("unhash", 0, bin_unhash, 1, -1, BIN_UNHASH, "adfms", NULL),
-    BUILTIN("unset", BINF_PSPECIAL, bin_unset, 1, -1, 0, "fmv", NULL),
+    BUILTIN("unset", BINF_PSPECIAL, bin_unset, 1, -1, BIN_UNSET, "fmv", NULL),
     BUILTIN("unsetopt", 0, bin_setopt, 0, -1, BIN_UNSETOPT, NULL, NULL),
     BUILTIN("wait", 0, bin_fg, 0, -1, BIN_WAIT, NULL, NULL),
     BUILTIN("whence", 0, bin_whence, 0, -1, 0, "acmpvfsSwx:", NULL),
@@ -4158,6 +4158,10 @@ bin_unhash(char *name, char **argv, Options ops, int func)
     for (; *argv; argv++) {
 	if ((hn = ht->removenode(ht, *argv))) {
 	    ht->freenode(hn);
+	} else if (func == BIN_UNSET && isset(POSIXBUILTINS)) {
+	    /* POSIX: unset: "Unsetting a variable or function that was *
+	     * not previously set shall not be considered an error."    */
+	    returnval = 0;
 	} else {
 	    zwarnnam(name, "no such hash table element: %s", *argv);
 	    returnval = 1;