Access non-path WSLENV variable from WSL environment - visual-studio-code

I'm new to WSL as a development environment, and I'm trying to set some environment variable to begin working on an open source project. In this case, a domain and secret key. I've followed the steps mentioned here https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/ and here https://medium.com/#kevinv92/how-to-use-wslenv-to-share-environment-variables-between-windows-and-wsl-c06099d5b901 and this is output:
Microsoft Windows [Version 10.0.19041.388]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\kyles>wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
C:\Users\kyles>echo %WSLENV%
MVC_FIREBASE_API_KEY/p:MVC_FIREBASE_DOMAIN/p
C:\Users\kyles>echo %MVC_FIREBASE_DOMAIN%
minimum-viable-ceremonies-dev
C:\Users\kyles>wsl
kylesnowschwartz#DESKTOP-VN55S9F:/mnt/c/Users/kyles$ echo $WSLENV
MVC_FIREBASE_API_KEY/p:MVC_FIREBASE_DOMAIN/p
kylesnowschwartz#DESKTOP-VN55S9F:/mnt/c/Users/kyles$ echo $MVC_FIREBASE_DOMAIN
Nothing is output when for the environment variable, as I am expecting. I would appreciate any help in understanding what I don't understand!

The Microsoft blog entry is a bit confusing. Fortunately your problem is quite simple: You are using path translation option /p but your environment variable is not a path!
Passing environment variable from Windows to WSL, use /u option:
Microsoft Windows [Version 10.0.19044.1706]
(c) Microsoft Corporation. All rights reserved.
C:\Users\arttu>set MVC_FIREBASE_DOMAIN=minimum-viable-ceremonies-dev
C:\Users\arttu>set WSLENV=%WSLENV%:MVC_FIREBASE_DOMAIN/u
C:\Users\arttu>wsl
$ echo $MVC_FIREBASE_DOMAIN
minimum-viable-ceremonies-dev

Related

How to force `dotnet` CLI to return non zero exit code?

I run dotnet from powershell script, and when I specify some unknown switch powershell does not detect any error. And output goes to stdout whereas I'd expect it to be stderr.
Is it a setting on dotnet or powershell side? I need script to fail in case of errors.
dotnet pack -dsfsdf Microsoft (R) Build Engine version
15.8.166+gd4e8d81a88 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1001: Unknown switch. Switch: -dsfsdf
For switch syntax, type "MSBuild /help"
Indeed dotnet-pack writes errors to stdout, however it sets exit code to 1 in case of unknown parameter. You can check it with following code:
dotnet pack -asd
echo $LASTEXITCODE

terminal.integrated.env.windows for Integrated Terminal

I'm trying to set variable before start the Integrated Terminal
User Setting:
{
"terminal.integrated.env.windows": {
"foo": "bar"
}
}
Then View > Integrated Terminal
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:\bar> echo $foo
PS C:\bar>
It's seem not work,
It's bug or I'm wrong?
VSCode Version: 1.16.1
PS: Already seem Set global $PATH environment variable in VS Code
Finally, yume-chan answer by question in
Ref: https://github.com/Microsoft/vscode/issues/34420#issuecomment-329705397
It's should be echo $Env:foo instead of echo $foo

cscript.exe doesn't read unicode script (UTF-8)

simply save the following in notepad using UTF-8
msgbox "你好"
double click or run it from command line
D:\>cscript.exe /u test-unicode.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
D:\test-unicode.vbs(1, 1) Microsoft VBScript compilation error: Invalid characte
r
is there any way to run the unicode script in Windows Script Host?
cscript.exe can run scripts saved using [Unicode] (seems UTF-16).

solaris zlogin run command from nosuperuser

i want execute long running command from global zone in csh shell in zlogin non-interactive mode
zlogin zone1 su - adm /usr/bin/stop_c &
Warning: no access to tty; thus no job control in this shell...
Oracle Corporation SunOS 5.10 Generic Patch January 2005
Badly placed ()'s
logout
Try this but its not helps me
zlogin zone1 su - adm /usr/bin/nohup /usr/bin/stop_c
Warning: no access to tty; thus no job control in this shell...
Oracle Corporation SunOS 5.10 Generic Patch January 2005
^?ELF^A^B^A^B^B^A^A^G≤4: Command not found
Variable syntax
logout
This is the supported way to run a command as a different user with zlogin:
zlogin -l adm zone1 /usr/bin/stop_c &

Windows Shell. Restoring Orig Files

After a quick google search I found this link: Mercurial: simple way to revert .orig files?, with the following line of code in the comment:
for /f %i in ('dir /s /b *.orig') do #copy %i %~dpni
In powershell, I tried running it, but I got the following error: Missing opening ( after kyeword for.
Is powershell not the correct way to run this code or is the syntax incorrect?
I am trying to revert my orig files back to their original version (get rid of the .orig extension). I am using windows so BASH is not an easy option.
The comment that snippet came from suggests that the environment you can run that line in is the "Windows command prompt with Command Extensions."
You can create that environment like so: cmd /e:on. It didn't seem like using powershell was the intention, but you could type cmd /e:on into the powershell console and get that environment.
PS C:\> cmd /e:on
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\> Command Prompt Input is Valid Here
You received that error because that syntax is incorrect for powershell -- for statements expect parameters in parenthesis. It should work once you're in the appropriate shell, though.