如何将此输出设置为CMD中的变量
git rev-parse --show-toplevel | sed -e s/\//\\/g
我试过了:
for /f "delims=" %%A in ('git rev-parse --show-toplevel | sed -e s/\//\\/g ')
do set "var=%%A"
答案 0 :(得分:0)
尝试转义管道(in bat shell, escape is '^
'):
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "delims=" %%A in ('git rev-parse --show-toplevel ^| sed -e s/\//\\/g ') do (
set "var=%%A"
)
echo "A='%A%'"