about summary refs log tree commit diff
path: root/Src/params.c
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-06-16 01:36:50 +0200
committerMikael Magnusson <mikachu@gmail.com>2015-06-17 02:26:17 +0200
commite55c16708320aee327fe192d543a25e05343fae5 (patch)
treeed05888ed41b29e9872e800374f4f0d486d507f1 /Src/params.c
parent2cfe892414a2c6af6fd7b569c18cffeff1e39310 (diff)
downloadzsh-e55c16708320aee327fe192d543a25e05343fae5.tar.gz
zsh-e55c16708320aee327fe192d543a25e05343fae5.tar.xz
zsh-e55c16708320aee327fe192d543a25e05343fae5.zip
35476: Allow setting $0 when POSIX_ARGZERO is not set
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/Src/params.c b/Src/params.c
index 98541a6da..3b757359b 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -196,7 +196,7 @@ static const struct gsu_integer ttyidle_gsu =
 { ttyidlegetfn, nullintsetfn, stdunsetfn };
 
 static const struct gsu_scalar argzero_gsu =
-{ argzerogetfn, nullstrsetfn, nullunsetfn };
+{ argzerogetfn, argzerosetfn, nullunsetfn };
 static const struct gsu_scalar username_gsu =
 { usernamegetfn, usernamesetfn, stdunsetfn };
 static const struct gsu_scalar dash_gsu =
@@ -4044,6 +4044,21 @@ lcsetfn(Param pm, char *x)
 }
 #endif /* USE_LOCALE */
 
+/* Function to set value for special parameter `0' */
+
+/**/
+static void
+argzerosetfn(UNUSED(Param pm), char *x)
+{
+    if (x) {
+	if (!isset(POSIXARGZERO)) {
+	    zsfree(argzero);
+	    argzero = ztrdup(x);
+	}
+	zsfree(x);
+    }
+}
+
 /* Function to get value for special parameter `0' */
 
 /**/