Windows上Ubuntu上的Bash启动参数

Twi*_*bie 5 windows bash windows-subsystem-for-linux

嗨,我想使用启动参数在Windows上启动bash.exe,并让外壳打开。我为此找到了msdn页面,但是如果尝试使用bash -c“ ls”运行它,则bash之后已经关闭。

我想在桌面上有一个链接,在该链接中我输入了ssh的登录命令。因此外壳应该保持打开状态,而不是执行命令然后退出。

ani*_*ane 5

man bash

   -c        If the -c option is present, then commands are read from the first non-option
             argument command_string.  If there are arguments  after  the  command_string,
             they are assigned to the positional parameters, starting with $0.
Run Code Online (Sandbox Code Playgroud)

因此,使用-c,外壳不是交互式的。如果要在运行初始命令后使用交互式shell,请从运行bash shell启动另一个交互式bash shell。

以您的示例为例:

bash -c 'ls; exec bash'
Run Code Online (Sandbox Code Playgroud)