Skip to content

Commit 23846ef

Browse files
committed
Optionally disallow empty environment values again
We just disabled the code that skips environment variables whose values are empty. However, this code was introduced a long time ago into Cygwin in d6b1ac7 (* environ.cc (build_env): Don't put an empty environment variable into the environment. Optimize use of "len". * errno.cc (ERROR_MORE_DATA): Translate to EMSGSIZE rather than EAGAIN., 2006-09-07), seemingly without any complaints. Meaning: There might very well be use cases out there where it makes sense to skip empty-valued environment variables. Therefore, it seems like a good idea to have a "knob" to turn it back on. With this commit, we introduce such a knob: by setting `noemptyenvvalues` the `MSYS` variable (or appending it if that variable is already set), users can tell the MSYS2 runtime to behave just like in the olden times. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 2897bc0 commit 23846ef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

winsup/cygwin/environ.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static char **lastenviron;
3636
/* Parse CYGWIN options */
3737

3838
static NO_COPY bool export_settings = false;
39+
static bool emptyenvvalues = true;
3940

4041
enum settings
4142
{
@@ -119,6 +120,7 @@ static struct parse_thing
119120
} known[] NO_COPY =
120121
{
121122
{"disable_pcon", {&disable_pcon}, setbool, NULL, {{false}, {true}}},
123+
{"emptyenvvalues", {&emptyenvvalues}, setbool, NULL, {{false}, {true}}},
122124
{"enable_pcon", {&disable_pcon}, setnegbool, NULL, {{true}, {false}}},
123125
{"error_start", {func: error_start_init}, isfunc, NULL, {{0}, {0}}},
124126
{"export", {&export_settings}, setbool, NULL, {{false}, {true}}},
@@ -1326,7 +1328,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
13261328
Note that this doesn't stop invalid strings without '=' in it
13271329
etc., but we're opting for speed here for now. Adding complete
13281330
checking would be pretty expensive. */
1329-
if (len == 1)
1331+
if (len == 1 || (!emptyenvvalues && !*rest))
13301332
continue;
13311333

13321334
/* See if this entry requires posix->win32 conversion. */

0 commit comments

Comments
 (0)