Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.1
X-Originating-IP: [86.21.161.213]
X-Spam: 0
X-Authority: v=2.1 cv=J5VXl1TS c=1 sm=1 tr=0 a=oo3MgO7t/4XyXFuSzI3dDQ==:117
 a=oo3MgO7t/4XyXFuSzI3dDQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10
 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=t-IPkPogAAAA:8
 a=xEOLKBfgW4r60dwEX0MA:9 a=CjuIK1q_8ugA:10 a=z9dJwno5l634igLiVhy-:22
 a=TwOW_m0CY6OjrxjWeTv9:22
Date: Sun, 8 May 2016 21:28:58 +0100
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: leading '=' in enviroment variable truncated
Message-ID: <20160508212858.384e3dbf@ntlworld.com>
In-Reply-To: <160508132406.ZM10234@torch.brasslantern.com>
References: <CAEyFG7ZkxS9iuVtEoJT2aa_ErBm=Nm6JqkpSgt=-=3P-nuZBtg@mail.gmail.com>
	<160508105949.ZM9904@torch.brasslantern.com>
	<20160508201217.5924511a@ntlworld.com>
	<160508132406.ZM10234@torch.brasslantern.com>
X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Seq: zsh-workers 38433

[apologies for duplicates, I think I sent the last reply to Bart.]

On Sun, 8 May 2016 13:24:06 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Astounding.
> 
> The Open Group spec for "setenv" explicitly prohibits "=" in the name,
> and says nothing about the value.  The source code for setenv.c on
> opensource.apple.com does nothing special with name or value.
> 
> How about this?

This tries to be smarter, but I don't know if it's worth it... it's
untested on the target system.

diff --git a/Src/zsh_system.h b/Src/zsh_system.h
index 811340d..4f3330b 100644
--- a/Src/zsh_system.h
+++ b/Src/zsh_system.h
@@ -729,7 +729,9 @@ extern char **environ;
  * we don't know how to do memory management on the values set.
  */
 #if defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
-# define USE_SET_UNSET_ENV
+# ifndef SETENV_MANGLES_EQUALS
+#  define USE_SET_UNSET_ENV
+# endif
 #endif
 
 
diff --git a/configure.ac b/configure.ac
index 9ce3a45..b5be67f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3031,6 +3031,27 @@ if test "x$dynamic" = xyes; then
   fi
 fi
 
+AH_TEMPLATE([SETENV_MANGLES_EQUALS],
+[Define to 1 if setenv removes a leading =])
+if test x$ac_cv_func_setsnv = xyes; then
+AC_CACHE_CHECK([if setenv removes a leading =],
+ zsh_cv_c_setenv_mangles_equals,
+ [AC_TRY_RUN([
+#include <string.h>
+   main()
+   {
+      setenv("NAME", "=VALUE", 1);
+      return strcmp((char *)getenv("NAME"), "=VALUE");
+   }
+   ],
+   zsh_cv_c_setenv_mangles_equals=yes,
+   zsh_cv_c_setenv_mangles_equals=no,
+   zsh_cv_c_setenv_mangles_equals=no)])
+   if test x$zsh_cv_c_setenv_mangles_equals = xyes; then
+     AC_DEFINE(SETENV_MANGLES_EQUALS)
+   fi
+fi
+
 if test "x$dynamic" = xyes; then
   zsh_SYS_DYNAMIC_CLASH
   zsh_SYS_DYNAMIC_GLOBAL

