Skip to content

Commit a097396

Browse files
authored
Optimize EXIT behaviour of batch script (flutter#8799)
Some Windows Versions close the entire shell if EXIT is called without /B. This also adds retry logic for downloading the Dart SDK.
1 parent a9ba0e2 commit a097396

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

bin/flutter.bat

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ SET dart=%dart_sdk_path%\bin\dart.exe
2929
SET pub=%dart_sdk_path%\bin\pub.bat
3030

3131
REM Test if Git is available on the Host
32-
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT 1
32+
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1
3333
REM Test if the flutter directory is a git clone, otherwise git rev-parse HEAD would fail
3434
IF NOT EXIST "%flutter_root%\.git" (
3535
ECHO Error: The Flutter directory is not a clone of the GitHub project.
36-
EXIT 1
36+
EXIT /B 1
3737
)
3838

3939
REM Ensure that bin/cache exists.
@@ -82,9 +82,8 @@ GOTO :after_subroutine
8282
CALL PowerShell.exe -ExecutionPolicy Bypass -Command "& '%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1'"
8383
SET exit_code=%ERRORLEVEL%
8484
IF %exit_code% NEQ 0 (
85-
ECHO Error: Unable to update Dart SDK.
86-
REM Do not use /B here, we want to exit out of the script, not just the subroutine
87-
EXIT %exit_code%
85+
ECHO Error: Unable to update Dart SDK. Retrying... Press Ctrl+C to abort.
86+
GOTO :do_sdk_update_and_snapshot
8887
)
8988

9089
:do_snapshot
@@ -111,4 +110,4 @@ IF /I "%exit_code%" EQU "253" (
111110
SET exit_code=%ERRORLEVEL%
112111
)
113112

114-
EXIT %exit_code%
113+
EXIT /B %exit_code%

0 commit comments

Comments
 (0)