On 09.01.2012 22:27, Michaƫl Michaud wrote: > Hi Ede, > > After so many years, I'm still struggling with batch pitfall like whitespaces > and other special chars. > Don't know why you used [], but I cannot change the jre by hand anymore. > I wanted to test with my 1.5 jvm : > set JAVA_HOME=C:\Program Files (x86)\Java\jre1.5.0_22 > > the batch stopped working until I changed > if NOT [%JAVA_HOME%]==[] set JAVA=%JAVA_HOME%\bin\%JAVA_BIN% > by > if NOT "%JAVA_HOME%"=="" set JAVA=%JAVA_HOME%\bin\%JAVA_BIN% > > Thanks to double check and to commit if you have a proper solution. >
ok, fixed. please doublecheck. the [] was introduced because it enables the cmd IF to survive variable containing quotes (cmd does not resolve these unlike unix shells) e.g. JAVA_HOME="fo o/b ar" and the concatenation %JAVA_HOME%\bla\bla which translates to "fo o/b ar"\bla\bla in cmd scripts. as quoting is really a mess because of the missing resolving (quote removal during assigning) i resorted to hack a dequote function which essentially strips quotes and the scripter can then be sure that set VAR="test" if "%VAR%" == "" ... wont fail because "%VAR%" accidentially translates to ""test"" which is of course invalid. backdraw is taht the scripter now has to make sure that a variable that might contain spaces is quoted manually. but that the same hassle one goes through with shell scripts. .. nice find, ede ------------------------------------------------------------------------------ RSA(R) Conference 2012 Mar 27 - Feb 2 Save $400 by Jan. 27 Register now! http://p.sf.net/sfu/rsa-sfdev2dev2 _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel