wsl executes only bash commands and not windows options - cmd

When I try to execute cmd commands such as wsl -l, wsl returns this message:
/bin/bash: -c: option requires an argument
However, using wsl as a bash command launcher works.
What do I have to do in order to use wsl windows options such as wsl -l, wsl --install, etc.?
Thanks in advance!

I assume that you've entered wsl command in the Linux terminal and when you did this the first time bash answered you that the command was not found , so you installed 'wsl' package. This is a completely different package. If you want to invoke Windows binaries from bash you should use .exe file extension. Try wsl.exe -l

Related

Why is $OSTYPE returning "linux-gnu" on Windows?

Problem
When I run a bash script on Windows:
bash my_script.sh
I get linux-gnu for $OSTYPE inside the script.
Why is this like this?
I assume that i have WSL installed is relevant here.
Tested in PowerShell and CMD.
Git bash is returning msys like expected! Thx #user1934428
Background
I want to start some python scripts from bash, but not inside WSL.
From my command line I reach different python versions on windows, but from inside the bash scripts it is using the one inside WSL (except for GitBash).
You're right, running the bash command in PowerShell or CMD will launch WSL to run your script. You confirm this (and see which version of WSL) by running cat /etc/issue in your bash script. Your WSL environment will have an independent set of environment variables (not just $OSTYPE). You can see this by comparing the output of Get-ChildItem -Path Env:\ in PowerShell to the output of env (after you launch bash from PowerShell).
I suspect that the python version discrepancy you're seeing is a result of the PATH variable in your WSL runtime not matching what you have set in your PowerShell environment. You can fix your version issue by setting an alias containing a path to the python executable you want to use by adding alias python=/c/path/to/python.exe to the start of your bash scripts.
Alternatively, you can use a tool like Cygwin or git-bash to run your scripts. I'm not sure if they will use the same path variables as Windows so you may need to set those manually too.

Exposing cmd.exe from zsh

On windows subsystem for linux, I can acces the native windows comand prompt through
$ cmd.exe [command]
However, when running oh-my-zsh, The cmd.exe api does not seem to be exposed...
$ cmd.exe
zsh: command not found: cmd.exe
How can I expose the cmd.exe api to be available in oh-my-zsh?
Found it!
Just had to set my PATH variable in zsh equal to the one in WSL (no zsh)...

Use WSL(Windows Subsystem for Linux) bash command in CMD

I am favorite user of WSL.
Before Restoring my Windows 10 OS, I setup WSL in my Windows and I didn't change any configuration. But One Day, the bash command were executed in CMD immediately. So, If I opened CMD and run a command such as 'ls', then result was the same in bash thing.
However now, I restore my windows and above command excuting no longer occurs. I often use bash commands, so I want to execute bash command in CMD. What should I do?

Windows/Cygwin equivalents of linux screen and $()?

I have a bash script that runs screen and uses $( command ) to execute the output of command. I need to port this script to run on Windows. I installed Cygwin to run this but it doesn't recognize screen as a command and I don't know the Windows equivalent of linux's $(). Any suggestions on how to do this in windows?
screen is not installed by default.
You need to explicitly install it using cygwin setup.
https://cygwin.com/faq.html#faq.setup.what-packages
$( command ) it is available in bash on Cygwin like on Linux

Using Windows subsystem for Linux in Sublime

For example, how to run "make" command in Bash instead of CMD ? I tried to write my own buildsystem "bash -c make", but sublime can't recognize commnad bash (which is added also to PATH). Thanks :)

Resources