Skip to content

Commit dbc4d4a

Browse files
authored
Fix -pw without password may take incorrect args (#17914)
1 parent aa7b275 commit dbc4d4a

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

scripts/sbin/windows/start-cli.bat

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ if /I "%~1"=="-u" (
6060
goto parse_args
6161
)
6262
if /I "%~1"=="-pw" (
63+
call :is_known_option "%~2"
6364
if "%~2"=="" (
6465
set "passwd_param=-pw"
6566
shift
67+
) else if "!IS_KNOWN_OPTION!"=="true" (
68+
set "passwd_param=-pw"
69+
shift
6670
) else (
6771
set "passwd_param=-pw %~2"
6872
shift
@@ -93,6 +97,23 @@ set "PARAMETERS=%PARAMETERS% %~1"
9397
shift
9498
goto parse_args
9599

100+
:is_known_option
101+
set "IS_KNOWN_OPTION=false"
102+
if /I "%~1"=="-h" set "IS_KNOWN_OPTION=true"
103+
if /I "%~1"=="-p" set "IS_KNOWN_OPTION=true"
104+
if /I "%~1"=="-u" set "IS_KNOWN_OPTION=true"
105+
if /I "%~1"=="-pw" set "IS_KNOWN_OPTION=true"
106+
if /I "%~1"=="-e" set "IS_KNOWN_OPTION=true"
107+
if /I "%~1"=="-help" set "IS_KNOWN_OPTION=true"
108+
if /I "%~1"=="-sql_dialect" set "IS_KNOWN_OPTION=true"
109+
if /I "%~1"=="-disableISO8601" set "IS_KNOWN_OPTION=true"
110+
if /I "%~1"=="-c" set "IS_KNOWN_OPTION=true"
111+
if /I "%~1"=="-timeout" set "IS_KNOWN_OPTION=true"
112+
if /I "%~1"=="-usessl" set "IS_KNOWN_OPTION=true"
113+
if /I "%~1"=="-ts" set "IS_KNOWN_OPTION=true"
114+
if /I "%~1"=="-tpw" set "IS_KNOWN_OPTION=true"
115+
exit /b 0
116+
96117
:after_parse
97118
REM Combine all parameters
98119
set "PARAMETERS=%host_param% %port_param% %user_param% %passwd_param% %sql_dialect_param% %PARAMETERS%"
@@ -139,4 +160,4 @@ REM Run CLI
139160
REM -------------------------------
140161
endlocal
141162

142-
exit /b %ERRORLEVEL%
163+
exit /b %ERRORLEVEL%

0 commit comments

Comments
 (0)