Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WSL,使用“运行linux命令”;wsl——执行官<;cmd>&引用;或;wsl--<;cmd>&引用;_Linux_Bash_Powershell_Windows Subsystem For Linux - Fatal编程技术网

WSL,使用“运行linux命令”;wsl——执行官<;cmd>&引用;或;wsl--<;cmd>&引用;

WSL,使用“运行linux命令”;wsl——执行官<;cmd>&引用;或;wsl--<;cmd>&引用;,linux,bash,powershell,windows-subsystem-for-linux,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. 但所有的产出似乎都是一样的。您如何解释从PowerShell提示符运行WSL Linux命令的这三种方式之间的区别?我认为这意味着WSL直接运行命令,而不是生成一个

wsl-h
显示以下内容:

    --exec, -e <CommandLine>   Execute the specified command without using the default Linux shell.
    --   Pass the remaining command line as is.

但所有的产出似乎都是一样的。您如何解释从PowerShell提示符运行WSL Linux命令的这三种方式之间的区别?

我认为这意味着WSL直接运行命令
,而不是生成一个shell进程来运行命令

例如,如果我运行:

wsl -e sleep 10
从另一个终端,我有:

root      1482     1  0 11:32 tty3     00:00:00 /init
ubuntu    1483  1482  0 11:32 tty3     00:00:00 sleep 10

我们可以看到
/init
sleep 10
的父级,中间没有外壳。

使用wsl/使用bin/bash。与wsl-e。。。。外壳为env。当您在wsl上运行shell脚本时,这具有更大的相关性。
root      1482     1  0 11:32 tty3     00:00:00 /init
ubuntu    1483  1482  0 11:32 tty3     00:00:00 sleep 10