我正在尝试在批处理脚本中执行以下操作:
@echo off
SETLOCAL
set BASHPATH="C:\Program Files (x86)\Git\bin\"
set PATH=%BASHPATH%;%PATH%
set COMMIT=%1
echo COMMIT: %COMMIT%
%BASHPATH%\bash -l -c "echo COMMIT: $COMMIT \ && git checkout -f $COMMIT \ && git submodule update -f \ && git clean -fdx \ && git submodule foreach git clean -fdx \ && call $SCRIPT_PATH\name_all.sh \ && call $SCRIPT_PATH\name_all_log.sh \ && cd FCW \ && cd ObjectDetectionTest \ && exit; bash";
set CYGWINPATH="C:\cygwin64\bin"
set PATH=%CYGWINPATH%;%PATH%
ENDLOCAL
但是当我运行脚本时,$COMMIT
会转换为空!那么,我做错了什么?
答案 0 :(得分:0)
从蝙蝠脚本中,我设法做到了:
set COMMIT=%1
echo COMMIT: %COMMIT%
bash -l -c "COMMIT=%COMMIT% bash -l -c 'echo \${COMMIT}'"
含义:
%COMMIT%
。COMMIT
中设置bash -c
后在bash中调用bash $