Yor*_*ubs 7 linux bash powershell windows-subsystem-for-linux
wsl -h显示以下内容:
--exec, -e <CommandLine> Execute the specified command without using the default Linux shell.
-- Pass the remaining command line as is.
Run Code Online (Sandbox Code Playgroud)
“不使用默认的 Linux shell”是什么意思(即,如果不是默认的 shell,它还会使用什么!?)?
此外,通过示例,我现在可以通过三种可能的方式ls从 PowerShell 提示符运行 Linux(即,这不会Get-ChildItem别名为ls,而是通过 WSL 的 Linux 命令):
PS C:\> wsl -e ls # Alternatively, wsl --exec ls
PS C:\> wsl -- ls
PS C:\> wsl ls
Run Code Online (Sandbox Code Playgroud)
但所有输出似乎都是相同的。您如何解释从 PowerShell 提示符运行 WSL Linux 命令的这三种方法之间的差异?
我认为这意味着 wsl 运行该命令directly,而不是生成一个 shell 进程来运行该命令。
例如,如果我运行:
wsl -e sleep 10
Run Code Online (Sandbox Code Playgroud)
从另一个终端,我有:
root 1482 1 0 11:32 tty3 00:00:00 /init
ubuntu 1483 1482 0 11:32 tty3 00:00:00 sleep 10
Run Code Online (Sandbox Code Playgroud)
我们可以看到/init是 的父级sleep 10,中间没有 shell。