mintty:如何在进程终止后保持输出可见?

nde*_*mou 5 cygwin mintty

我有一个启动 cygwin bash 脚本的桌面快捷方式,我希望 mintty 终端在我的脚本终止后保持打开状态,以便我可以查看它的输出。为此,我使用-h alwaysmintty 选项[1]。

窗口确实保持打开状态,但当我的脚本终止时,mintty 无助地清除了输出(!!!)。看起来像是一个糟糕的笑话。我错过了什么吗?即使使用只有回显的一行脚本,我也验证了这种行为。


注意[1]-h在手册页中是这样描述的:

-h, --hold never|start|error|always

Determine whether to keep the terminal window open when the command has finished and no more processes are connected to the terminal. 
Run Code Online (Sandbox Code Playgroud)

小智 5

我进行了一些测试,-h always薄荷选项按预期工作;屏幕没有被清除,窗户保持打开状态。

这是我用于运行脚本的确切快捷方式“目标”:

C:\cygwin64\bin\mintty.exe -h always /usr/bin/bash -l ~/helloworld.bash
Run Code Online (Sandbox Code Playgroud)

我正在使用 mintty 2.7.7 (x86_64-pc-cygwin)。

希望升级 mintty 和/或使用上面所示的语法能够为您解决问题。read如果没有,您可以通过添加如下命令来强制脚本本身暂停:

echo 'Script end.  Press ENTER to close'
read
Run Code Online (Sandbox Code Playgroud)


nde*_*mou 2

我正在运行我的脚本,因此bash --login在终止时它会隐式调用/etc/bash.bash_logout其中包含运行的行/usr/bin/clear“以增加隐私”)。


致谢:我在这个错误报告中找到了答案,其中包括以下有用的解释:

>  Hmm, the screen clearing is done by the latest /etc/bash.bash_logout:

# when leaving the console clear the screen to increase privacy   if
[ "$SHLVL" = 1 ]; then
    [ -x /usr/bin/clear ] && /usr/bin/clear   
fi
Run Code Online (Sandbox Code Playgroud)