linux - WSL,使用“wsl --exec”运行 linux 命令" 或 "wsl --"
问题描述
wsl -h
显示以下内容:
--exec, -e <CommandLine> Execute the specified command without using the default Linux shell.
-- Pass the remaining command line as is.
“不使用默认的 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
但是所有的输出似乎都是一样的。您将如何解释从 PowerShell 提示符运行 WSL Linux 命令的这三种方式之间的区别?
解决方案
我认为这意味着 wsl 运行命令directly
,而不是产生一个 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
,中间没有外壳。
推荐阅读
- javascript - 直接传递 process.stdout.write 与通过回调传递不同的输出?
- sql - SQL 聚合函数 MAX 通过加入删除重复项
- c - 在 C 中“固定”大角度
- image-processing - 为什么我不能使 2D 高斯收敛?
- excel - 如何在特定文本上方添加空白行?
- node.js - React + NodeJS - nodemailer 谷歌云功能
- node.js - 使用 Typescript 为可能的 null 值添加一个接口
- visual-studio - 使用 MSBuild、VS 2019、Platform Toolset v142 编译时如何指定“目标平台版本”和“目标平台最低版本”
- laravel - 在 laravel mix 中使用 vue 或 jquery
- python - 如何在python中通过re从字符串中获取数字和字母?