--- a/smalltalk.bat Tue Jul 18 14:00:22 2017 +0200
+++ b/smalltalk.bat Thu Jul 20 12:35:09 2017 +0200
@@ -53,7 +53,7 @@
:: Versions =
:: ==========
:: This script
-SET batch_script_version=1.4.6
+SET batch_script_version=1.4.8
:: Smalltalk/X
SET stx_version=6.2.6
@@ -196,21 +196,33 @@
:: Stx bin directory =
:: ===================
IF "!stx.stx_bin_dir!" NEQ "" (
- CALL :expand !stx.stx_bin_dir! stx_bin_dir
+ CALL :expand_path !stx.stx_bin_dir! stx.stx_bin_dir
+ IF ERRORLEVEL 1 (
+ ECHO "[ERROR] -> stx.stx_bin_dir <- variable error in check your configuration file -> !stx.stx_bin_dir! <-"
+ GOTO :EOF
+ )
)
:: ===================================
:: Stx quick start and image details =
:: ===================================
IF "!stx.image_path!" NEQ "" (
- CALL :expand !stx.image_path! stx.image_path
+ CALL :expand_path !stx.image_path! stx.image_path
+ IF ERRORLEVEL 1 (
+ ECHO "[ERROR] -> stx.image_path <- variable error in check your configuration file -> !stx.image_path! <-"
+ GOTO :EOF
+ )
)
:: =============
:: Stx logging =
:: =============
IF "!stx.log_directory!" NEQ "" (
- CALL :expand !stx.log_directory! stx.log_directory
+ CALL :expand_path !stx.log_directory! stx.log_directory
+ IF ERRORLEVEL 1 (
+ ECHO "[ERROR] -> stx.log_directory <- variable error in check your configuration file -> !stx.log_directory! <-"
+ GOTO :EOF
+ )
)
:: ==================================================================================
@@ -298,13 +310,13 @@
:: Allowed values ASCII, UTF8 (default), UTF16 (in Microsoft world that is called Unicode), UTF32
:: Note: If UTF16 is used you can view log file while StX is running, in all other cases you have to close StX before viewing the file
IF "!stx.log_file_encoding!" EQU "ASCII" (
- SET "stx.log_suffix=_ascii!stx.log_suffix!"
+ SET "stx.log_suffix="_ascii!stx.log_suffix:"=!""
) ELSE IF "!stx.log_file_encoding!" EQU "UTF8" (
- SET "stx.log_suffix=_utf8!stx.log_suffix!"
+ SET "stx.log_suffix="_utf8!stx.log_suffix:"=!""
) ELSE IF "!stx.log_file_encoding!" EQU "UTF16" (
- SET "stx.log_suffix=_utf16!stx.log_suffix!"
+ SET "stx.log_suffix="_utf16!stx.log_suffix:"=!""
) ELSE IF "!stx.log_file_encoding!" EQU "UTF32" (
- SET "stx.log_suffix=_utf32!stx.log_suffix!"
+ SET "stx.log_suffix="_utf32!stx.log_suffix:"=!""
) ELSE (
SET "message="Invalid log file encoding: !stx.log_file_encoding!. Fix it and run the script again.""
SET __numeric.exit_value=1
@@ -356,7 +368,6 @@
:: ==============================================
:: Checking the PowerShell file (.ps1) presence =
:: ==============================================
-
IF NOT EXIST "!powershell_script_file!" (
SET "message="PowerShell file missing: !powershell_script_path!smalltalk.ps1. Fix it.""
SET __numeric.exit_value=1
@@ -364,13 +375,18 @@
GOTO :EOF
)
-:: =====================================================================
-:: Validate __binary for TRUE^/FALSE and if it does not contain spaces =
-:: =====================================================================
-:: Checks if the variable contains correctly written TRUE^/FALSE
-:: additionally it also checks if additional space was not added by mistake
-:: var -7 extracts the last 7 characters from var
+
+:: =======================
+:: Variables' validation =
+:: =======================
IF "!stx.verify_variables_syntax!" EQU "TRUE" (
+ REM must be used (inside IF^^!)
+ REM =====================================================================
+ REM Validate __binary for TRUE^/FALSE and if it does not contain spaces =
+ REM =====================================================================
+ REM Checks if the variable contains correctly written TRUE^/FALSE
+ REM additionally it also checks if additional space was not added by mistake
+ REM var -7 extracts the last 7 characters from var
FOR /F "tokens=3 delims=^." %%A IN ('SET stx.__binary.') DO (
SET temp_test=%%A
IF "!temp_test:~-5!" EQU "=TRUE" (
@@ -439,6 +455,115 @@
)
)
)
+ REM must be used (inside IF^^!)
+ REM ===============================================================
+ REM Validate path variables to contain double quotes or backslash =
+ REM ===============================================================
+
+ REM ========================================================
+ REM Check beginning of the string to contain double quotes =
+ REM ========================================================
+ REM Checking image variables
+ SET "correct_substring=!stx.image_name:~0,1!"
+ IF !correct_substring! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.image_name variable: - !stx.image_name! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ SET "correct_substring=!stx.image_suffix:~0,1!"
+ IF !correct_substring! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.image_suffix variable: - !stx.image_suffix! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+
+ REM Checking logging variables
+ SET "correct_substring=!stx.log_name:~0,1!"
+ IF !correct_substring! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.log_name variable: - !stx.log_name! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ SET "correct_substring=!stx.log_suffix:~0,1!"
+ IF !correct_substring! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.log_suffix variable: - !stx.log_suffix! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ SET "correct_substring=!log_filename:~0,1!"
+ IF !correct_substring! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at log_filename variable: - !log_filename! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ REM clearing temp variable
+ SET correct_substring=
+
+ REM ===========================================================================================
+ REM Checking string's end to contain either backslash and double quotes or just double quotes =
+ REM ===========================================================================================
+ REM Checking image variables
+ IF !stx.stx_bin_dir:~-2! NEQ \^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected. Missing backslash at variable stx.stx_bin_dir: - !stx.stx_bin_dir! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+
+ REM Checking image variables
+ IF !stx.image_path:~-2! NEQ \^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected. Missing backslash at variable stx.image_path: - !stx.image_path! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ IF !stx.image_name:~-1! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.image_name variable: - !stx.image_name! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ IF !stx.image_suffix:~-1! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.image_suffix variable: - !stx.image_suffix! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+
+ REM Checking logging variables
+ IF !stx.log_directory:~-2! NEQ \^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected. Missing backslash at variable stx.log_directory: - !stx.log_directory! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ IF !stx.log_name:~-1! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.log_name variable: - !stx.log_name! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ IF !stx.log_suffix:~-1! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at stx.log_suffix variable: - !stx.log_suffix! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ IF !log_filename:~-1! NEQ ^" (
+ SET __numeric.exit_value=1
+ SET "message="Incorrect configuration detected missing double quotes at log_filename variable: - !log_filename! -""
+ CALL :exit_sequence !message!
+ GOTO :EOF
+ )
+ REM must be used (inside IF^^!)
+ REM ===========================================
+ REM Print validation message if user wants to =
+ REM ===========================================
IF "!stx.verify_print_message!" EQU "TRUE" (
CALL :print_message !use_color! !stx.stdout_VerboseBackgroundColor! !stx.stdout_VerboseForegroundColor! "===============================" "Variable syntax validated. =" "==============================="
ECHO:
@@ -528,24 +653,24 @@
:: STX_LIB_DIR=<path_to_support_files>
:: Change to the specified bin directory
-pushd "!stx_bin_dir!"
+pushd "!stx.stx_bin_dir!"
IF EXIST "stx-bin.com" (
IF "!stx.__binary.run_via_shell!" EQU "TRUE" (
SET "selected_executable=stx-bin.com"
) ELSE (
SET "selected_executable=stx-bin.exe"
)
- SET "stx_home=!stx_bin_dir:"=!.."
- SET "stx_topdir=!stx_bin_dir:"=!..\lib\smalltalkx\!stx_version!"
- SET "stx_libdir=!stx_bin_dir:"=!..\lib\smalltalkx\!stx_version!\lib"
- SET "smalltalk_executable=!stx_bin_dir:"=!!selected_executable!"
+ SET "stx_home=!stx.stx_bin_dir:"=!.."
+ SET "stx_topdir=!stx.stx_bin_dir:"=!..\lib\smalltalkx\!stx_version!"
+ SET "stx_libdir=!stx.stx_bin_dir:"=!..\lib\smalltalkx\!stx_version!\lib"
+ SET "smalltalk_executable=!stx.stx_bin_dir:"=!!selected_executable!"
) ELSE IF EXIST "stx.com" (
IF "!stx.__binary.run_via_shell!" EQU "TRUE" (
SET "selected_executable=stx.com"
) ELSE (
SET "selected_executable=stx.exe"
)
- SET smalltalk_executable="!stx_bin_dir:"=!!selected_executable!"
+ SET smalltalk_executable="!stx.stx_bin_dir:"=!!selected_executable!"
) ELSE (
SET "message="The executable stx-bin^.com;exe perhaps stx^.com;exe NOT found.""
@@ -1278,12 +1403,13 @@
SET "%~1=!_time_in_seconds!"
GOTO :EOF
+
:: =============================================
:: Expanding variables from configuration file =
:: =============================================
:: Must be last in this section
-:expand
-SET "%~2=%~1"
+:expand_path
+SET "%2=%1"
GOTO :EOF