some absurdities w/ if exist and escaping with caret and ""
Posted: 11 Sep 2013 15:52
some absurdities with if exist and escaping with caret and ""
I don't know if this is just with if exist,
can anybody explain this behavior?
exhibit a
I test to see if a directory exists. but get a different result based on whether I included quotes or not.
exhibit b
Normally one only needs to place quotes around the part where there is an issue and it's fine. But here, I get a different result with each of these
exhibit c
Normally one can interchange ^ and "" when it comes to a single character, but not here. I don't see why.
I don't know if this is just with if exist,
can anybody explain this behavior?
exhibit a
I test to see if a directory exists. but get a different result based on whether I included quotes or not.
Code: Select all
C:\>if exist c:\abcde\nul echo yeah
yeah
C:\>if exist "c:\abcde\nul" echo yeah
C:\>
exhibit b
Normally one only needs to place quotes around the part where there is an issue and it's fine. But here, I get a different result with each of these
Code: Select all
C:\>IF exist c:\program fi"les (x86)"\gnuwin32\bin echo yeah
C:\>IF exist "c:\program files (x86)"\gnuwin32\bin echo yeah
yeah
C:\>
exhibit c
Normally one can interchange ^ and "" when it comes to a single character, but not here. I don't see why.
Code: Select all
(i'll just do a cd and dir /ad/b so you know what directory tree I have)
C:\abcde\a(b)c>
C:\>dir c:\abcde /ad/b
a(b)c
asd
C:\>
C:\>if exist c:\ab" "cde\a(b)c echo yeah
yeah
C:\>if exist c:\ab^ cde\a(b)c echo yeah
C:\>