You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alistair Young edited this page Apr 2, 2021
·
2 revisions
If you have attempted this, you will note that the following code doesn't work:
wsl genie -c 'XYZ=abc env'
This is because genie -c invokes the command directly, not using an intermediate shell. (As you can see by running wsl genie -c ps - you should see the runinwsl helper, ps itself, and maybe a system process like (sd-pam), but no shell.
Setting an environment variable on the command like that is a shell function, which is why it doesn't work. To make it work, you need to explicitly run the command inside a shell, thus:
wsl genie -c sh -c 'XYZ=abc env'
NOTE: This is not necessary when using the RunInGenie helper application, because it does run the command in a shell, using the above technique.