Windows 批处理文件意外退出
我正在尝试创建一个bat文件,它将获取一个git存储库并将其下载到一个特定的目录 运行此脚本时出现的错误是:Windows 批处理文件意外退出,windows,batch-file,command-line,Windows,Batch File,Command Line,我正在尝试创建一个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 respons
' 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
)
@echo关闭
标题初学者工具包
cls
echo“注意:此脚本将从@NicholasAdamou的GitHub下载'CodeKit Starter Kit'存储库。”
set/p response=“是否继续?”
如果/i“%response%”=y(
后藤:下载套件
:下载套件
cls
echo“从@NicholasAdamou的GitHub下载CodeKit初学者工具包存储库。”
设置“文件路径=%~dp0”
cd%filePath%
cd./区
git克隆https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git ‘起动套件(代码套件)’
)
如果/i“%response%”=n(
呼叫出口
)
我不明白
设置“文件路径=%~dp0”
尝试用双引号替换git命令中的单引号
无论如何,我们现在是2016年,是学习powershell的时候了:-)
我不明白
设置“文件路径=%~dp0”
尝试用双引号替换git命令中的单引号
无论如何,我们现在是2016年,是学习powershell的时候了:-)
您需要对git行的括号进行转义,如下所示:
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit^)'
这是因为批处理将右括号视为特殊字符您需要转义git行的括号,如下所示:
git clone https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git 'StarterKit (CodeKit^)'
这是因为批处理将右括号视为特殊字符作为响应:我不理解设置“filePath=%~dp0”,我试图让脚本将位置设置为文件的cwd。我试过,“尝试用双引号替换git命令中的单引号。”结果不起作用。因此,我将尝试您的代码片段,看看是否有效。对于
“filePath=%~dp0”
,批处理代码的意思是将变量filePath设置为包含当前批处理文件的路径。对此,我不理解set“filePath=%~dp0”,我正在尝试获取脚本以将位置设置为文件的cwd。我试过,“尝试用双引号替换git命令中的单引号。”结果不起作用。所以我会试试你的代码片段,看看它是否有效。至于“filePath=%~dp0”
,它的批处理代码意思是设置变量filePath以包含当前批处理文件的路径谢谢你的回答…它更有意义。不是绝对确定,但据我所知,git
也接受双引号,所以这也应该起作用:git克隆https://github.com/NicholasAdamou/CodeKit-Starter-Kit.git “起动器套件(代码套件)”
;所以没有必要逃避任何事情…谢谢你的回答…它更有意义。不是绝对确定,但就我所记得的,git
也接受双引号,所以这也应该起作用:git clonehttps://github.com/NicholasAdamou/CodeKit-Starter-Kit.git “起动器套件(代码套件)”
;所以没有必要逃避任何事情。。。