This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 080a810b4e8 Modify script to use local environment variable changes 
and avoid pol… (#16541)
080a810b4e8 is described below

commit 080a810b4e81df95fc1e16f58b5704aca5e8b098
Author: Hongzhi Gao <[email protected]>
AuthorDate: Thu Oct 9 15:57:15 2025 +0800

    Modify script to use local environment variable changes and avoid pol… 
(#16541)
    
    * Modify script to use local environment variable changes and avoid 
polluting global environment
    
    * fix start-cli-table.bat
    
    * fix start-cli-table.bat
---
 scripts/sbin/windows/start-cli-table.bat | 19 ++++++---
 scripts/sbin/windows/start-cli.bat       | 70 ++++++++++++++++----------------
 2 files changed, 50 insertions(+), 39 deletions(-)

diff --git a/scripts/sbin/windows/start-cli-table.bat 
b/scripts/sbin/windows/start-cli-table.bat
index c3f960e3548..7812ff565b2 100644
--- a/scripts/sbin/windows/start-cli-table.bat
+++ b/scripts/sbin/windows/start-cli-table.bat
@@ -21,9 +21,6 @@
 @echo off
 
 REM -------------------------------
-REM Default SQL dialect
-if "%DEFAULT_SQL_DIALECT%"=="" set DEFAULT_SQL_DIALECT=table
-
 REM Path to start-cli.bat script (adjust if needed)
 set CLI_SCRIPT=%~dp0start-cli.bat
 
@@ -35,5 +32,17 @@ if not exist "%CLI_SCRIPT%" (
 )
 
 REM Execute main script with:
-REM Pass all arguments through
-"%CLI_SCRIPT%" %*
\ No newline at end of file
+REM Pass all arguments through and add -sql_dialect table if not already 
specified
+setlocal
+set ARGS=%*
+if "%ARGS%"=="" (
+    "%CLI_SCRIPT%" -sql_dialect table
+) else (
+    echo %ARGS% | find /i "-sql_dialect " >nul
+    if errorlevel 1 (
+        "%CLI_SCRIPT%" -sql_dialect table %*
+    ) else (
+        "%CLI_SCRIPT%" %*
+    )
+)
+endlocal
\ No newline at end of file
diff --git a/scripts/sbin/windows/start-cli.bat 
b/scripts/sbin/windows/start-cli.bat
index be2c31872fb..aa22808ed39 100644
--- a/scripts/sbin/windows/start-cli.bat
+++ b/scripts/sbin/windows/start-cli.bat
@@ -18,23 +18,28 @@ REM specific language governing permissions and limitations
 REM under the License.
 REM
 
+REM ==========================================================
+REM Apache IoTDB CLI Launcher
+REM ==========================================================
+
+setlocal enabledelayedexpansion
+
 REM -------------------------------
 REM Default SQL dialect
-if "%DEFAULT_SQL_DIALECT%"=="" set DEFAULT_SQL_DIALECT=tree
+if "%DEFAULT_SQL_DIALECT%"=="" set "DEFAULT_SQL_DIALECT=tree"
 
 REM Default connection parameters
-set user_param=-u root
-set passwd_param=-pw root
-set host_param=-h 127.0.0.1
-set port_param=-p 6667
-set sql_dialect_param=-sql_dialect %DEFAULT_SQL_DIALECT%
-set PARAMETERS=
+set "user_param=-u root"
+set "passwd_param=-pw root"
+set "host_param=-h 127.0.0.1"
+set "port_param=-p 6667"
+set "sql_dialect_param=-sql_dialect %DEFAULT_SQL_DIALECT%"
+set "PARAMETERS="
 
 REM -------------------------------
-REM Normalize script path to ensure %~dp0 resolves correctly
-REM Using pushd/popd with %CD% is more reliable than %~dp0 alone
+REM Normalize script path
 pushd "%~dp0" >nul 2>&1
-set SCRIPT_DIR=%CD%
+set "SCRIPT_DIR=%CD%"
 popd >nul 2>&1
 
 REM -------------------------------
@@ -49,78 +54,75 @@ REM Parse command-line arguments
 if "%~1"=="" goto after_parse
 
 if /I "%~1"=="-u" (
-    set user_param=-u %~2
+    set "user_param=-u %~2"
     shift
     shift
     goto parse_args
 )
 if /I "%~1"=="-pw" (
     if "%~2"=="" (
-        set passwd_param=-pw
+        set "passwd_param=-pw"
         shift
     ) else (
-        set passwd_param=-pw %~2
+        set "passwd_param=-pw %~2"
         shift
         shift
     )
     goto parse_args
 )
 if /I "%~1"=="-h" (
-    set host_param=-h %~2
+    set "host_param=-h %~2"
     shift
     shift
     goto parse_args
 )
 if /I "%~1"=="-p" (
-    set port_param=-p %~2
+    set "port_param=-p %~2"
     shift
     shift
     goto parse_args
 )
 if /I "%~1"=="-sql_dialect" (
-    set sql_dialect_param=-sql_dialect %~2
+    set "sql_dialect_param=-sql_dialect %~2"
     shift
     shift
     goto parse_args
 )
 
-REM Any other arguments
-set PARAMETERS=%PARAMETERS% %~1
+set "PARAMETERS=%PARAMETERS% %~1"
 shift
 goto parse_args
 
 :after_parse
-
 REM Combine all parameters
-set PARAMETERS=%host_param% %port_param% %user_param% %passwd_param% 
%sql_dialect_param% %PARAMETERS%
-
+set "PARAMETERS=%host_param% %port_param% %user_param% %passwd_param% 
%sql_dialect_param% %PARAMETERS%"
 
 REM CLI configuration
-set IOTDB_CLI_CONF=%IOTDB_HOME%\conf
-set MAIN_CLASS=org.apache.iotdb.cli.Cli
+set "IOTDB_CLI_CONF=%IOTDB_HOME%\conf"
+set "MAIN_CLASS=org.apache.iotdb.cli.Cli"
 
-REM -------------------------------
 REM CLASSPATH setup
-set CLASSPATH=%IOTDB_HOME%\lib\*
+set "CLASSPATH=%IOTDB_HOME%\lib\*"
 
-REM -------------------------------
 REM JAVA executable
 if defined JAVA_HOME (
     if exist "%JAVA_HOME%\bin\java.exe" (
-        set JAVA=%JAVA_HOME%\bin\java.exe
+        set "JAVA=%JAVA_HOME%\bin\java.exe"
     ) else (
-        set JAVA=java
+        set "JAVA=java"
     )
 ) else (
-    set JAVA=java
+    set "JAVA=java"
 )
 
-REM -------------------------------
 REM JVM options
-set 
IOTDB_CLI_PARAMS=-Dlogback.configurationFile=%IOTDB_CLI_CONF%\logback-cli.xml
-set JVM_OPTS=-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8 
--add-opens=java.base/java.lang=ALL-UNNAMED
+set 
"IOTDB_CLI_PARAMS=-Dlogback.configurationFile=%IOTDB_CLI_CONF%\logback-cli.xml"
+set "JVM_OPTS=-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8 
--add-opens=java.base/java.lang=ALL-UNNAMED"
 
-REM -------------------------------
 REM Run CLI
 "%JAVA%" %JVM_OPTS% %IOTDB_CLI_PARAMS% -cp "%CLASSPATH%" %MAIN_CLASS% 
%PARAMETERS%
-exit /b %ERRORLEVEL%
+
+REM -------------------------------
+endlocal
+
+exit /b %ERRORLEVEL%
\ No newline at end of file

Reply via email to