Spend like 3 hours searching some thread were jeb explained why it's important to always add an extra exclamation mark.
Had it documented but then deleted it because I thought I would remember such basic...

Didn't find the original thread I was after but then bumped into this post from jeb which comes pretty close and even has some WOW to it

So I ended up writing my own little tutorial. I WOW somewhere else.jeb wrote:Code: Select all
SETLOCAL EnableDelayedExpansion
echo ^^^^--"^^" 1 "^^" ^^^^
echo ^^^^--"^^" 2 "^^" ^^^^ !
echo !^^^^--"^^" 3 "^^" ^^^^
echo:!^^^^--"^^" 4 "^^" ^^^^ WOW
--- OUTPUT ----
^^--"^^" 1 "^^" ^^
^--"^" 2 "^" ^
^--"^" 3 "^" ^
^--"^" 4 "^^" ^^ WOW
Code: Select all
@echo off
echo.
echo.An exclamation mark should always be added so that carets between quotes are
echo.always stripped in the same manner.
echo.
echo.disableDelayedExpansion doesn't care about the extra exclamation mark.
setlocal disableDelayedExpansion
set "$=with exclamation mark ^ "^^^^"" !
set "$"
set "$=without exclamation mark ^ "^^^^""
set "$"
set "$=with exclamation mark ^ "^^^^""
set "$=%$%" !
set "$"
set "$=without exclamation mark ^ "^^^^""
set "$=%$%"
set "$"
echo.
echo.But enableDelayedExpansion does !
setlocal enableDelayedExpansion
set "$=with exclamation mark ^^ "^^^^^^^^"" !
set "$"
set "$=without exclamation mark ^^ "^^^^^^^^""
set "$"
set "$=with exclamation mark ^^ "^^^^^^^^""
set "$=%$%" !
set "$"
set "$=without exclamation mark ^^ "^^^^^^^^""
set "$=%$%"
set "$"
echo.
echo.Some more interesting behavior of enableDelayedExpansion
echo.^^^^--"^^" 1 "^^" ^^^^
echo.^^^^--"^^" 2 "^^" ^^^^ !
echo.!^^^^--"^^" 3 "^^" ^^^^
echo !^^^^--"^^" 4 "^^" ^^^^ WOW
echo.
pause
exit
Code: Select all
An exclamation mark should always be added so that carets between quotes are
always stripped in the same manner.
disableDelayedExpansion doesn't care about the extra exclamation mark.
$=with exclamation mark ^ "^^"
$=without exclamation mark ^ "^^"
$=with exclamation mark ^ "^"
$=without exclamation mark ^ "^"
But enableDelayedExpansion does !
$=with exclamation mark ^ "^^"
$=without exclamation mark ^^ "^^^^"
$=with exclamation mark ^ "^"
$=without exclamation mark ^^ "^^"
Some more interesting behavior of enableDelayedExpansion
^^--"^^" 1 "^^" ^^
^^--"^^" 2 "^" ^
^--"^" 3 "^^" ^^
^--"^" 4 "^" ^ WOW
Druk op een toets om door te gaan. . .
http://www.dostips.com/forum/viewtopic.php?f=3&t=1910
Magic: all we don't understand.
There is interest in documenting various techniques but the problem is usually a lack of understanding and or time.
Recently I discover http://www.allenware.com/icsw/icswidx.htm ( which used to be my favorite DOS learning site as a beginner because of the way it looked and felt ) has now gone off-line before I had the chance to index and port some ideas.
