zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: leading '=' in enviroment variable truncated
Date: Sun, 8 May 2016 21:28:58 +0100	[thread overview]
Message-ID: <20160508212858.384e3dbf@ntlworld.com> (raw)
In-Reply-To: <160508132406.ZM10234@torch.brasslantern.com>

[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


  reply	other threads:[~2016-05-08 20:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-07 16:21 Jacob Lowe
2016-05-07 16:43 ` Jacob Lowe
2016-05-08 17:59 ` Bart Schaefer
2016-05-08 19:12   ` Peter Stephenson
2016-05-08 20:24     ` Bart Schaefer
2016-05-08 20:28       ` Peter Stephenson [this message]
2016-05-08 21:58         ` Bart Schaefer
2016-05-08 22:16           ` Bart Schaefer
2016-05-09  9:11             ` Peter Stephenson
2016-05-09 14:52               ` Bart Schaefer
2016-05-09  2:14 ` Bart Schaefer
2016-05-09  2:19   ` Jacob Lowe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160508212858.384e3dbf@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).