Code: Select all
@echo off & setlocal disabledelayedexpansion
for /f "tokens=1-12" %%a in ("%% ~ * = ; , ! ) ( | > <") do (
echo #1: [%%a] [%%b] [%%c] [%%d] [%%e] [%%f] [%%g] [%%h] [%%i] [%%j] [%%k] [%%l]
)
for /f "usebackq tokens=1-13" %%a in ('%%^ ~^ *^ ^=^ ^;^ ^,^ !^ ^)^ ^(^ ^|^ ^>^ ^<^ ^"') do (
echo #2: [%%a] [%%b] [%%c] [%%d] [%%e] [%%f] [%%g] [%%h] [%%i] [%%j] [%%k] [%%l] [%%m]
)
for /f "usebackq tokens=1-7 delims= " %%a in ('a = b ; c , d') do (
echo #3: [%%a] [%%b] [%%c] [%%d] [%%e] [%%f] [%%g]
)
for /f "usebackq tokens=1-7 delims= " %%a in ('a ^= b ^; c ^, d') do (
echo #4: [%%a] [%%b] [%%c] [%%d] [%%e] [%%f] [%%g]
)
for /f "usebackq tokens=1-7 delims= " %%a in ('a^ ^=^ b^ ^;^ c^ ^,^ d') do (
echo #5: [%%a] [%%b] [%%c] [%%d] [%%e] [%%f] [%%g]
)
endlocal & goto :eof
Output, verified under XP 32b, Vista 64b and Win7 64b.
Code: Select all
C:\tmp>usebackq-test
#1: [%] [~] [*] [=] [;] [,] [!] [)] [(] [|] [>] [<]
#2: [%] [~] [*] [=] [;] [,] [!] [)] [(] [|] [>] [<] ["]
#3: [a] [b] [c] [d] [] [] []
#4: [a] [=] [b] [;] [c] [,] [d]
#5: [a] [=] [b] [;] [c] [,] [d]
One more oddity, this one in XP alone, is that unless the spaces themselves are escaped (as is done on line #5) random errors occur once every few runs, like the following.
Code: Select all
C:\tmp>usebackq-test
#1: [%] [~] [*] [=] [;] [,] [!] [)] [(] [|] [>] [<]
#2: [%] [~] [*] [=] [;] [,] [!] [)] [(] [|] [>] [<] ["]
#3: [a] [b] [c] [d] [] [] []
The system cannot find the file
♥♣?§?§.
#4: [a] [=] [b] [;] [c] [,] [d]
The system cannot find the file ♠?x§?§Y§%a in.
#5: [a] [=] [b] [;] [c] [,] [d]
Liviu