{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/BashOnWindows/issues/1494","repository_url":"https://api.github.com/repos/Microsoft/BashOnWindows","labels_url":"https://api.github.com/repos/Microsoft/BashOnWindows/issues/1494/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/BashOnWindows/issues/1494/comments","events_url":"https://api.github.com/repos/Microsoft/BashOnWindows/issues/1494/events","html_url":"https://github.com/Microsoft/BashOnWindows/issues/1494","id":194960738,"number":1494,"title":"Allow environment to be set when invoking Win32 process from WSL","user":{"login":"dra27","id":5250680,"avatar_url":"https://avatars.githubusercontent.com/u/5250680?v=3","gravatar_id":"","url":"https://api.github.com/users/dra27","html_url":"https://github.com/dra27","followers_url":"https://api.github.com/users/dra27/followers","following_url":"https://api.github.com/users/dra27/following{/other_user}","gists_url":"https://api.github.com/users/dra27/gists{/gist_id}","starred_url":"https://api.github.com/users/dra27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dra27/subscriptions","organizations_url":"https://api.github.com/users/dra27/orgs","repos_url":"https://api.github.com/users/dra27/repos","events_url":"https://api.github.com/users/dra27/events{/privacy}","received_events_url":"https://api.github.com/users/dra27/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-12-12T12:18:36Z","updated_at":"2016-12-13T16:16:49Z","closed_at":null,"body":"When invoking a Win32 process from an LXSS process, it would be useful to have *any* way of passing some environment variables - for example, via execve(2). The new WSL->Win32 interop is game-changingly great, but having to dance via `cmd /c set FOO=bar && some command` is really awkward (and brittle, given the quoting nightmare).\r\n\r\nFor example, launch bash from a VS2015 Native Tools Command Prompt (ensure FOO unset or run `set FOO=` before invoking bash):\r\n\r\nlinux.c\r\n```c\r\n#include <stdio.h>\r\n#include <unistd.h>\r\nint main(void) {\r\n  char* newargv[] = { \"win.exe\", NULL };\r\n  char* newenviron[] = { \"FOO=bar\", NULL };\r\n  printf(\"Hello world! (LXSS)\\n\");\r\n  execve(\"./win.exe\", newargv, newenviron);\r\n  return 1;\r\n}\r\n```\r\n\r\nwin.c\r\n```c\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\nint main(void) {\r\n  printf(\"Hello world! (Win32)\\nFOO=%s\\n\", getenv(\"FOO\"));\r\n  return 0;\r\n}\r\n```\r\n\r\nSession (`sudo apt-get install gcc` if you don't have gcc!):\r\n```\r\ngcc -o linux linux.c\r\ncl.exe /nologo /Fewin.exe win.c\r\n./linux\r\n```\r\noutput is:\r\n\r\n```\r\nHello world! (LXSS)\r\nHello world! (Win32)\r\nFOO=(null)\r\n```\r\n\r\ndesired output would be `FOO=bar` at the end (naturally, if win.c is compiled with gcc and \"./win.exe\" changed to \"./win\" then this \"works\").\r\n\r\nBuild 14986."},"comment":{"url":"https://api.github.com/repos/Microsoft/BashOnWindows/issues/comments/266783006","html_url":"https://github.com/Microsoft/BashOnWindows/issues/1494#issuecomment-266783006","issue_url":"https://api.github.com/repos/Microsoft/BashOnWindows/issues/1494","id":266783006,"user":{"login":"aseering","id":363982,"avatar_url":"https://avatars.githubusercontent.com/u/363982?v=3","gravatar_id":"","url":"https://api.github.com/users/aseering","html_url":"https://github.com/aseering","followers_url":"https://api.github.com/users/aseering/followers","following_url":"https://api.github.com/users/aseering/following{/other_user}","gists_url":"https://api.github.com/users/aseering/gists{/gist_id}","starred_url":"https://api.github.com/users/aseering/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseering/subscriptions","organizations_url":"https://api.github.com/users/aseering/orgs","repos_url":"https://api.github.com/users/aseering/repos","events_url":"https://api.github.com/users/aseering/events{/privacy}","received_events_url":"https://api.github.com/users/aseering/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T16:16:49Z","updated_at":"2016-12-13T16:16:49Z","body":"Regarding implementing this -- I personally see WSL's current behavior of stripping environment variables as the feature.\r\n\r\nI would consider it to be a bug if my entire Linux environment showed up in Windows for a reason analogous to why it would be a bug if WSL used my Windows home directory as its home directory:  Linux and Windows use the same names for different things; in general I don't want my Linux state stomping on my Windows state, nor vice versa.\r\n\r\nThere are various clever things that WSL could do.  For example, capture environment variables that are set in the new Windows process but not in its parent.  I am in general skeptical of this approach; too much magic.  I'd rather be explicit."}}
{"actor":{"display_login":"aseering"}}