我需要在Cygwin的帮助下运行cmd-recursive.sh
脚本。有.bat
会将当前脚本的路径设置为变量。
此命令在Cygwin终端下运行时更改目录就很好了。
cd "$(echo "D:\real\Path with Spaces\TargetFolder" | sed "s/^D:/\/cygdrive\/d/;s/\\\/\//g;")"
executor.bat
@echo off
set mypath=%cd%
C:\cygwin64\bin\bash -l "cd ""$(echo %mypath% | sed "s/^D:/\/cygdrive\/d/;s/\\\/\//g;")"""; ./cmd-recursive.sh"
执行结果:
/usr/bin/bash: cd "$(echo D:\real\Path with Spaces\TargetFolder | sed s/D://cygdrive/d/;s/\///g;)";: No such file or directory