Quotes, Spaces in Args interpreted inconsistently?
Posted: 18 Sep 2009 18:24
Hi,
Consider the following test.bat file:
@echo off
echo 1:%1 2:%2 3:%3
now run each of the following commandlines:
C:\>test.bat hi bye now
1:hi 2:bye 3:now
C:\>test.bat ""hi" "bye"" now again
1:""hi" "bye"" 2:now 3:again
C:\>test.bat ""hi hi" "bye"" now again
1:""hi 2:hi" "bye"" 3:now
How are quoted strings within quoted args working? The 2nd commandline seems fine, but throw a space in the inner quoted string and it gets messed up (the 3rd command)
An explanation of what's happening or a different method for passing along multiple quoted strings in one quoted arg would be much appreciated.
Thanks,
Paul
Consider the following test.bat file:
@echo off
echo 1:%1 2:%2 3:%3
now run each of the following commandlines:
C:\>test.bat hi bye now
1:hi 2:bye 3:now
C:\>test.bat ""hi" "bye"" now again
1:""hi" "bye"" 2:now 3:again
C:\>test.bat ""hi hi" "bye"" now again
1:""hi 2:hi" "bye"" 3:now
How are quoted strings within quoted args working? The 2nd commandline seems fine, but throw a space in the inner quoted string and it gets messed up (the 3rd command)
An explanation of what's happening or a different method for passing along multiple quoted strings in one quoted arg would be much appreciated.
Thanks,
Paul