本帖最后由 Pchief 于 2014-12-22 16:35 编辑
我的代码是这样:- if [%2] equ [] (
- echo no arg!
- goto endp
- )
-
- setlocal EnableDelayedExpansion
- set argline=%*
- set /a in_quote=0
-
- :loop1
- if !argline:~0,1! == ^" (
- set /a in_quote=1-!in_quote!
- goto strip1st
- )
- if !in_quote! equ 1 goto strip1st
- if !argline:~0,1! == ^ goto endp
-
- :strip1st
- set argline=!argline:~1!
- goto loop1
-
-
- :endp
- echo !argline!
- endlocal
- pause
复制代码 把这段代码存为文件 repl_np.bat,运行结果如下- >test
-
- >call "C:\Documents and Settings\User\桌面\batch_test\repl_np.bat" notepad C:
- \"Program Files"\sc1\sc1.exe
-
- >if [C:\"Program Files"\sc1\sc1.exe] EQU [] (
- echo no arg!
- goto endp
- )
-
- >setlocal EnableDelayedExpansion
-
- >set argline=notepad C:\"Program Files"\sc1\sc1.exe
-
- >set /a in_quote=0
- 此时不应有 1!。
- >if !argline:~0,1! == ^" (
- >
复制代码 其中 call 那一行是我运行的实际命令行,请教一下那个“此时不应有1!。”出现的原因? |