当程序使用 Command 打开 Bash 到 运行 脚本时,Bash 立即关闭而没有 运行ning 脚本

When program uses Command to open Bash to run a script, Bash closes immediately without running the script

我有一个简单的、已经可以工作的 bash 脚本设置,用于在 Windows 上的游戏前端 EmulationStation 中使用特定程序启动特定文件。

但前端通过命令提示符路由其操作。当命令通过 Bash 用于 运行 脚本时,Bash shell 只是打开然后立即关闭。

Here's an image of what shows for the instant before Bash closes.

这仅在首先通过单独的命令提示符时发生,例如 Windows 命令提示符或 Git 命令提示符。 运行 直接通过 git-bash shell 使用适当参数的脚本工作得很好。

如果你出于任何原因想看脚本,这里是:

#!/bin/bash

defaultemulaunch="V:/Emulation/.emulationstation/systems/retroarch/retroarch.exe -L "V:/Emulation/.emulationstation/systems/retroarch/cores/bsnes_mercury_accuracy_libretro.dll" \"\""

emu1names=(\
    "(1999) Fire Emblem - Thracia 776.smc")

emu1launch="V:/Emulation/.emulationstation/systems/retroarch/retroarch.exe -L "V:/Emulation/.emulationstation/systems/retroarch/cores/snes9x_libretro.dll" \"\""

gamename=`basename ""`
for index in ${!emu1names[*]}
    do
        game=${emu1names[index]}
        if [ "$game" == "$gamename" ]; then
        eval "$emu1launch"
    fi
done

eval "$defaultemulaunch"

但值得指出的是,在从单独的命令提示符启动进程时尝试 运行 any bash 脚本时会发生这种情况。

注意: Git安装在仿真前端所在的硬盘上(V:)---不在用户目录或程序目录中系统的 OS/boot 驱动器 (C:)。我提到这个是因为 git-bash 在一个明显的 "login" 步骤失败,除非直接启动时感觉它可能是默认文件路径问题。

检查该程序是否仍然 open/close a Windows 从 CMD 执行时:

bash -c '/v/path/to/bash/script'

你的情况:

set PATH=V:\Emulation\
set GIT_HOME=V:\Emulation\Git
set PATH=%GIT_HOME%;%GIT_HOME%\bin;%GIT_HOME%\usr\bin;%GIT_HOME%\mingw64\bin;%PATH

然后:

cd V:/Emulation/.emulationstation/roms/snes/
bash -c './gamelaunch.sh "./(1990) F-Zero.sfc"'

我通常制作一个 run.bat 脚本,它将:

  • 设置正确的PATH
  • 启动正确的脚本

这样,对于我的任何项目,我只需输入 运行。
它 运行s.