我相信這個問題是其實不是quotation marks,但是你使用^
做了續行,這實際上逃避了下一行的第一個字符;所以代碼部分...:
(
"C:\Program Files\7-Zip\7z.exe"^
a^
"%%G.7z"^
"%%G\"^
-m0=BZip2^
-mx=9)
...實際上是由命令解釋器讀取...:
("C:\Program Files\7-Zip\7z.exe" ^a ^"%G.7z" ^"%G\" ^-m0=BZip2 ^-mx=9)
...這導致了一些逃脫引號^"
。特殊字符如SPACE和插入符號^
如果它們出現在一對""
中,則不會被檢測到。因此有解決的逃逸和tokenising命令行後,下面的令牌收到:
( // the opening parenthesis is detected
"C:\Program Files\7-Zip\7z.exe" // a single token as the spaces are in between `""`
a // `^a` becomes `a`
^"%G.7z" ^"%G\" ^-m0=BZip2 ^-mx=9) /* the first `^"` is just a literal character `"`
without any function, opposed to a non-escaped `"`;
the next `^` appears in between two functional `""`,
hence it is kept; the fourth `"` is another opening
one, so the rest of the line appears quoted, leading
to the next `^`s being kept too and the `)` not to
be recognised as the closing parenthesis, so there
appears one `)` missing in the code */
如果你之前有一個或多個的空格每續行,你不再是無意逃避一些功能特徵,但第一SPACE,...:
(
"C:\Program Files\7-Zip\7z.exe"^
a^
"%%G.7z"^
"%%G\"^
-m0=BZip2^
-mx=9)
...所以它成爲解釋爲...:
( "C:\Program Files\7-Zip\7z.exe"^a^"%G.7z"^"%G\"^-m0=BZip2^-mx=9)
...這裏逃脫的空格請勿打擾,所以線標記化到:
( // the opening parenthesis is detected
"C:\Program Files\7-Zip\7z.exe" // a single token as the spaces are in between `""`
a // `a` is kept unaltered
"%G.7z" // this is a correctly quoted token
"%G\" // this too
-m0=BZip2 // this is an unquoted token
-mx=9 // and this too
) /* the closing parenthesis is detected now properly,
because it does no longer appear quoted */