diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index daef751a67..5673ff876c 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -326,6 +326,7 @@ static win_env conv_envvars[] = {NL ("HOME="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, {NL ("LD_LIBRARY_PATH="), NULL, NULL, env_plist_to_posix, env_plist_to_win32, true}, + {NL ("SHELL="), NULL, NULL, env_path_to_posix, env_path_to_win32, true, true}, {NL ("TMPDIR="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, {NL ("TMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, {NL ("TEMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false}, @@ -354,7 +355,7 @@ static const unsigned char conv_start_chars[256] = WC, 0, 0, 0, WC, 0, 0, 0, /* 80 */ /* P Q R S T U V W */ - WC, 0, 0, 0, WC, 0, 0, 0, + WC, 0, 0, WC, WC, 0, 0, 0, /* 88 */ /* x Y Z */ 0, 0, 0, 0, 0, 0, 0, 0, @@ -405,6 +406,8 @@ win_env::add_cache (const char *in_posix, const char *in_native) native = (char *) realloc (native, namelen + 1 + strlen (in_native)); stpcpy (stpcpy (native, name), in_native); } + else if (skip_if_empty && !*in_posix) + native = (char *) calloc(1, 1); else { tmp_pathbuf tp; @@ -471,6 +474,8 @@ posify_maybe (char **here, const char *value, char *outenv) return; int len = strcspn (src, "=") + 1; + if (conv->skip_if_empty && !src[len]) + return; /* Turn all the items from c:; into their mounted equivalents - if there is one. */ diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h index b54971079b..c009f5d776 100644 --- a/winsup/cygwin/environ.h +++ b/winsup/cygwin/environ.h @@ -23,7 +23,7 @@ struct win_env char *native; ssize_t (*toposix) (const void *, void *, size_t); ssize_t (*towin32) (const void *, void *, size_t); - bool immediate; + bool immediate, skip_if_empty; void __reg3 add_cache (const char *in_posix, const char *in_native = NULL); const char * get_native () const {return native ? native + namelen : NULL;} const char * get_posix () const {return posix ? posix : NULL;}