从 Windows 的某个目录中开始 bash

Start bash in certain directory from Windows

我正在尝试在“/mnt”目录中启动 Bash.exe。

以下命令正确启动 bash:

C:\Windows\Sysnative\bash.exe

我有以下 .bat 文件:

C:\Windows\Sysnative\bash.exe -c "cd /mnt/"

不幸的是,这没有任何作用。这同样适用于:

C:\Windows\Sysnative\bash.exe --cd "/mnt/"

尝试:

C:\Windows\Sysnative\bash.exe -c "cd /mnt/ ; exec bash"

这会启动一个 Bash 进程,该进程 cds 到 '/mnt/',然后用一个新的(交互式)Bash 进程替换它自己,即 运行 在 '/mnt/ ' 目录。

以上代码仅经过简单测试,可能满足也可能不满足您的要求。有关替代方案,请参阅 run bash command in new shell and stay in new shell after this command executes 和 "Linked" 页面。