问题
Disclaimer: I'm not a batch files guru, just digging my way with the help of Google and SO. Also note that I'm trying to run this batch file as a Custom Action in SourceTree.
The following simple SET command doesn't seem to assign value to the variable:
SET MYVAR = %1
ECHO "%MYVAR%"
ECHO "!MYVAR!"
ECHO %1
The first ECHO above returns ""
; the second one "!MYVAR!"
, whereas the last one returns the actual value of command-line parameter. How can I assign value to MVAR
?
回答1:
set
is sensitive to spaces on each side of the =
. You are setting a variable named myvar[Space}
来源:https://stackoverflow.com/questions/36277001/simple-set-not-working-in-batch-file