GitBash-“一个;“没有此类文件”;使用cmd.exe中的完全限定路径运行bash脚本

GitBash-“一个;“没有此类文件”;使用cmd.exe中的完全限定路径运行bash脚本,bash,git-bash,Bash,Git Bash,Git for windows安装bash,并且可以从windows命令提示符获得bash.exe 启动bash脚本失败: bash.exe D:\path\to\script.sh /bin/bash: D:\path\to\script.sh: No such file or directory 但是,此文件存在: type D:\path\to\script.sh <<< output >>> 它也没有: echo '/d/path/to/scri

Git for windows安装bash,并且可以从windows命令提示符获得bash.exe

启动bash脚本失败:

bash.exe D:\path\to\script.sh
/bin/bash: D:\path\to\script.sh: No such file or directory 
但是,此文件存在:

type D:\path\to\script.sh
<<< output >>>
它也没有:

echo '/d/path/to/script.sh' | bash.exe
打字

cat /d/path/to/script.sh
但是,在bash.exe中可以工作

/编辑: 设备名称的大写似乎没有任何改变。 及


也不起作用。

尝试在命令提示符下不带任何参数启动bash.exe。
然后执行df-m,这将显示驱动器的安装位置。
我的系统的输出示例:

$ df -m
Filesystem           1M-blocks   Used Available Use% Mounted on
C:/Program Files/Git    241166 196593     44574  82% /
O:                      798717 739944     58774  93% /o
U:                      798717 739944     58774  93% /u
Y:                      798717 739944     58774  93% /y
正如您所看到的,安装git的驱动器作为root安装,但只有git安装目录。
这意味着如果在您的系统上Git安装在d上:这可能是您的问题。

也许可以选择将脚本放在Git安装目录中的某个位置。

猜测一下,试试
bash.exe d:/path/to/script.sh
/d
是bash语法糖,windows不知道它
bash-c“source/d/path/to/script.sh”
值得考虑。它不安装在d上,而d:安装在/d/。看起来还好吧?
bash.exe \\d\\path\\to\\script.sh
$ df -m
Filesystem           1M-blocks   Used Available Use% Mounted on
C:/Program Files/Git    241166 196593     44574  82% /
O:                      798717 739944     58774  93% /o
U:                      798717 739944     58774  93% /u
Y:                      798717 739944     58774  93% /y