我正在尝试创建一个bat文件,该文件将获取一个git存储库并将其下载到特定的目录中。
运行此脚本时遇到的错误是:
' was unexpected at this time. 这是我的代码:
@echo off
TITLE Starter Kit
cls
echo "Note: This script will download the 'CodeKit-Starter-Kit' repository from @NicholasAdamou's GitHub."
set /p response="Do you want to continue? <y/n>"
if /i "%response%"=="y" (
goto :downloadKit
:downloadKit
cls
echo "Downloading the CodeKit-Starter-Kit repository from @NicholasAdamou's GitHub."
set "filePath=%~dp0"
cd %filePath%
cd ../dist
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit)'
)
if /i "%response%"=="n" (
call exit
)发布于 2016-03-03 12:50:55
您需要转义git行的括号,如下所示:
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit^)'这是因为批处理视图将括号关闭为特殊字符。
发布于 2016-03-03 12:28:23
我不明白"filePath=%~dp0“一套
尝试用双引号代替git命令中的单引号。
总之,我们在2016年,是时候学习powershell了:-)
$filepath="$home\\dp0"
read-host -prompt "Do you want download it ? " -outvariable response
if ( $response -eq "y"){
set-location "$filepath\\dist"
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit)'
}https://stackoverflow.com/questions/35771450
复制相似问题