Index: main/trunk/greenstone2/setup.bat
===================================================================
--- main/trunk/greenstone2/setup.bat	(revision 20999)
+++ main/trunk/greenstone2/setup.bat	(revision 22318)
@@ -1,3 +1,6 @@
 @echo off
+
+setlocal enabledelayedexpansion
+
 pushd "%CD%"
 CD /D "%~dp0"
@@ -17,10 +20,10 @@
 echo.
 
-if "%OS%" == "Windows_NT" goto WinNT
-if "%OS%" == "" goto Win95
-if "%GSDLLANG%" == "en" echo Setup failed - your PATH has not been set
-if "%GSDLLANG%" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
-if "%GSDLLANG%" == "fr" echo Echc de l'installation - votre variable PATH n'a pas t ajuste
-if "%GSDLLANG%" == "ru" echo áâ ­®¢ª  ­¥ ã€ « áì -  ­¥ ¡ë« ãáâ ­®¢«¥­
+if "!OS!" == "Windows_NT" goto WinNT
+if "!OS!" == "" goto Win95
+if "!GSDLLANG!" == "en" echo Setup failed - your PATH has not been set
+if "!GSDLLANG!" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
+if "!GSDLLANG!" == "fr" echo Echc de l'installation - votre variable PATH n'a pas t ajuste
+if "!GSDLLANG!" == "ru" echo áâ ­®¢ª  ­¥ ã€ « áì -  ­¥ ¡ë« ãáâ ­®¢«¥­
 goto End
 
@@ -30,11 +33,11 @@
 
 REM Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
-if exist "%GSDLHOME%\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=%GSDLHOME%\bin\windows\ghostscript\bin\gsdll32.dll
-if exist "%GSDLHOME%\bin\windows\ghostscript\lib\*.*" set GS_LIB=%GSDLHOME%\bin\windows\ghostscript\lib
-if exist "%GSDLHOME%\bin\windows\ghostscript\bin\*.*" set PATH=%GSDLHOME%\bin\windows\ghostscript\bin;%PATH%
-if exist "%GSDLHOME%\bin\windows\imagemagick\*.*" set PATH=%GSDLHOME%\bin\windows\imagemagick;%PATH%
+if exist "!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll
+if exist "!GSDLHOME!\bin\windows\ghostscript\lib\*.*" set GS_LIB=!GSDLHOME!\bin\windows\ghostscript\lib
+if exist "!GSDLHOME!\bin\windows\ghostscript\bin\*.*" set PATH=!GSDLHOME!\bin\windows\ghostscript\bin;!PATH!
+if exist "!GSDLHOME!\bin\windows\imagemagick\*.*" set PATH=!GSDLHOME!\bin\windows\imagemagick;!PATH!
 
-if "%GS_CP_SET%" == "yes" goto Success
-set PATH=%GSDLHOME%\bin\windows\perl\bin;%GSDLHOME%\bin\windows;%GSDLHOME%\bin\script;%PATH%
+if "!GS_CP_SET!" == "yes" goto Success
+set PATH=!GSDLHOME!\bin\windows\perl\bin;!GSDLHOME!\bin\windows;!GSDLHOME!\bin\script;!PATH!
 set GS_CP_SET=yes
 goto Success
@@ -52,11 +55,11 @@
 
 REM Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
-if exist "%GSDLHOME%\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL="%GSDLHOME%\bin\windows\ghostscript\bin\gsdll32.dll"
-if exist "%GSDLHOME%\bin\windows\ghostscript\lib\*.*" set GS_LIB="%GSDLHOME%\bin\windows\ghostscript\lib"
-if exist "%GSDLHOME%\bin\windows\ghostscript\bin\*.*" set PATH="%GSDLHOME%\bin\windows\ghostscript\bin";"%PATH%"
-if exist "%GSDLHOME%\bin\windows\imagemagick\*.*" set PATH="%GSDLHOME%\bin\windows\imagemagick";"%PATH%"
+if exist "!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL="!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll"
+if exist "!GSDLHOME!\bin\windows\ghostscript\lib\*.*" set GS_LIB="!GSDLHOME!\bin\windows\ghostscript\lib"
+if exist "!GSDLHOME!\bin\windows\ghostscript\bin\*.*" set PATH="!GSDLHOME!\bin\windows\ghostscript\bin";"!PATH!"
+if exist "!GSDLHOME!\bin\windows\imagemagick\*.*" set PATH="!GSDLHOME!\bin\windows\imagemagick";"!PATH!"
 
-if "%GS_CP_SET%" == "yes" goto Success
-set PATH="%GSDLHOME%\bin\windows\perl\bin";"%GSDLHOME%\bin\windows";"%GSDLHOME%\bin\script";"%PATH%"
+if "!GS_CP_SET!" == "yes" goto Success
+set PATH="!GSDLHOME!\bin\windows\perl\bin";"!GSDLHOME!\bin\windows";"!GSDLHOME!\bin\script";"!PATH!"
 set GS_CP_SET=yes
 goto Success
@@ -64,31 +67,31 @@
 
 :Success
-if "%GSDLLANG%" == "en" echo.
-if "%GSDLLANG%" == "en" echo Your environment has successfully been set up to run Greenstone.
-if "%GSDLLANG%" == "en" echo Note that these settings will only have effect within this MS-DOS
-if "%GSDLLANG%" == "en" echo session. You will therefore need to rerun setup.bat if you want
-if "%GSDLLANG%" == "en" echo to run Greenstone programs from a different MS-DOS session.
-if "%GSDLLANG%" == "en" echo.
+if "!GSDLLANG!" == "en" echo.
+if "!GSDLLANG!" == "en" echo Your environment has successfully been set up to run Greenstone.
+if "!GSDLLANG!" == "en" echo Note that these settings will only have effect within this MS-DOS
+if "!GSDLLANG!" == "en" echo session. You will therefore need to rerun setup.bat if you want
+if "!GSDLLANG!" == "en" echo to run Greenstone programs from a different MS-DOS session.
+if "!GSDLLANG!" == "en" echo.
 
-if "%GSDLLANG%" == "es" echo.
-if "%GSDLLANG%" == "es" echo Su ambiente ha sido configurado para correr los programas Greenstone.
-if "%GSDLLANG%" == "es" echo Recuerde que estos ajustes £nicamente tendr n efecto dentro de esta sesi¢n
-if "%GSDLLANG%" == "es" echo MS-DOS. Por lo tanto deber  ejecutar nuevamente setup.bat si desea
-if "%GSDLLANG%" == "es" echo correr los programas de Greenstone desde una sesi¢n MS-DOS diferente.
-if "%GSDLLANG%" == "es" echo.
+if "!GSDLLANG!" == "es" echo.
+if "!GSDLLANG!" == "es" echo Su ambiente ha sido configurado para correr los programas Greenstone.
+if "!GSDLLANG!" == "es" echo Recuerde que estos ajustes £nicamente tendr n efecto dentro de esta sesi¢n
+if "!GSDLLANG!" == "es" echo MS-DOS. Por lo tanto deber  ejecutar nuevamente setup.bat si desea
+if "!GSDLLANG!" == "es" echo correr los programas de Greenstone desde una sesi¢n MS-DOS diferente.
+if "!GSDLLANG!" == "es" echo.
 
-if "%GSDLLANG%" == "fr" echo.
-if "%GSDLLANG%" == "fr" echo Votre environnement a t configure avec succs pour excuter Greenstone
-if "%GSDLLANG%" == "fr" echo Notez que ces paramtrages n'auront d'effet que dans cette session MS-DOS.
-if "%GSDLLANG%" == "fr" echo Vous devrez par consquent rexcuter setup.bat si vous voulez faire
-if "%GSDLLANG%" == "fr" echo lancer des programmes Greenstone dans une autre session MS-DOS.
-if "%GSDLLANG%" == "fr" echo.
+if "!GSDLLANG!" == "fr" echo.
+if "!GSDLLANG!" == "fr" echo Votre environnement a t configure avec succs pour excuter Greenstone
+if "!GSDLLANG!" == "fr" echo Notez que ces paramtrages n'auront d'effet que dans cette session MS-DOS.
+if "!GSDLLANG!" == "fr" echo Vous devrez par consquent rexcuter setup.bat si vous voulez faire
+if "!GSDLLANG!" == "fr" echo lancer des programmes Greenstone dans une autre session MS-DOS.
+if "!GSDLLANG!" == "fr" echo.
 
-if "%GSDLLANG%" == "ru" echo.
-if "%GSDLLANG%" == "ru" echo  è¥ ®ªàãŠ¥­š¥ ¡ë«® ãá¯¥è­® ­ áâà®¥­®, çâ®¡ë ãáâ ­®¢šâì Greenstone ¡à âšâ¥
-if "%GSDLLANG%" == "ru" echo ¢­š¬ ­š¥, çâ® íâš ­ §­ ç¥­šï ¡ã€ãâ â®«ìª® š¬¥âì íää¥ªâ ¢ ¯à¥€¥« å íâ®£® MS DOS
-if "%GSDLLANG%" == "ru" echo á¥áášï. ë ¡ã€¥â¥ ¯®íâ®¬ã €®«Š­ë ¯®¢â®à­® ã¯à ¢«ïâì setup.bat, ¥á«š ë å®âšâ¥
-if "%GSDLLANG%" == "ru" echo ã¯à ¢«ïâì ¯à®£à ¬¬ ¬š ¥«ñ­ëå š§¢¥àŠ¥­­ëå ¯®à®€ ®â à §«šç­®© á¥áášš MS DOS.
-if "%GSDLLANG%" == "ru" echo.
+if "!GSDLLANG!" == "ru" echo.
+if "!GSDLLANG!" == "ru" echo  è¥ ®ªàãŠ¥­š¥ ¡ë«® ãá¯¥è­® ­ áâà®¥­®, çâ®¡ë ãáâ ­®¢šâì Greenstone ¡à âšâ¥
+if "!GSDLLANG!" == "ru" echo ¢­š¬ ­š¥, çâ® íâš ­ §­ ç¥­šï ¡ã€ãâ â®«ìª® š¬¥âì íää¥ªâ ¢ ¯à¥€¥« å íâ®£® MS DOS
+if "!GSDLLANG!" == "ru" echo á¥áášï. ë ¡ã€¥â¥ ¯®íâ®¬ã €®«Š­ë ¯®¢â®à­® ã¯à ¢«ïâì setup.bat, ¥á«š ë å®âšâ¥
+if "!GSDLLANG!" == "ru" echo ã¯à ¢«ïâì ¯à®£à ¬¬ ¬š ¥«ñ­ëå š§¢¥àŠ¥­­ëå ¯®à®€ ®â à §«šç­®© á¥áášš MS DOS.
+if "!GSDLLANG!" == "ru" echo.
 
 :End
@@ -104,5 +107,5 @@
 if exist apache-httpd (
   echo Adding in executable path for apache-httpd
-  set PATH=%GSDLHOME%\apache-httpd\%GSDLOS%\bin;%PATH%
+  set PATH=!GSDLHOME!\apache-httpd\!GSDLOS!\bin;!PATH!
 )
 
@@ -115,8 +118,10 @@
     cd ..
   )
-  set PATH=%GSDLHOME%\local\bin;%PATH%
+  set PATH=!GSDLHOME!\local\bin;!PATH!
 )
 
 :: test writability of GSDLHOME
-@call "%GSDLHOME%\bin\script\checkwritability.bat"
+@call "!GSDLHOME!\bin\script\checkwritability.bat"
 popd
+
+endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%
