简体   繁体   English

bash 如何执行命令而不退出?

[英]bash how to exec a command not exit?

I had a command:我有一个命令:

"D:\Program Files\Git\bin\bash.exe" --login -c "git log -2"

but when I exec the such shell script, it print the result and quick exit .但是当我执行这样的 shell 脚本时,它会打印结果并快速退出

I search bash refrence:我搜索 bash 参考:

https://www.gnu.org/software/bash/manual/bash.html#Invoking-Bash https://www.gnu.org/software/bash/manual/bash.html#Invoking-Bash

-c

Read and execute commands from the first non-option argument command_string, then exit.从第一个非选项参数 command_string 读取并执行命令,然后退出。

I do not want exit.我不想退出。 I want the command can pring log and hold on, so I can see it.我希望命令可以登录并保持,以便我可以看到它。

So what should I do?所以我该怎么做?

Three options (at least):三个选项(至少):

  1. Install git properly in your Windows, so you can just run git log directly, without the need to run bash first.在您的 Windows 中正确安装 git,这样您就可以直接运行git log ,而无需先运行 bash。
  2. Run the same command you used in a Windows console.运行您在 Windows 控制台中使用的相同命令。
  3. Run the same command, only with another command that waits for any key to be pressed, like:运行相同的命令,只使用另一个等待按下任何键的命令,例如:

    "D:\\Program Files\\Git\\bin\\bash.exe" --login -c "git log -2 ; read -n1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM