Skip to content

Refactor bin/ shell scripts for better performance and safety#182674

Merged
auto-submit[bot] merged 4 commits intoflutter:masterfrom
kevmoo:script_cleanup
Feb 23, 2026
Merged

Refactor bin/ shell scripts for better performance and safety#182674
auto-submit[bot] merged 4 commits intoflutter:masterfrom
kevmoo:script_cleanup

Conversation

@kevmoo
Copy link
Contributor

@kevmoo kevmoo commented Feb 20, 2026

  • Utilized native bash parameter expansion and file reading mechanisms like $(< file) instead of sub-shelling external invocations like $(cat file).

  • Enforced path-safety across internal directory traversals by appending -- to cd and rm commands, insulating scripts against files/folders that might start with a hyphen.

  • Restructured chmod application using find -exec ... + to batch parameter arguments, bypassing the overhead of spinning up individual process instances per matched file.

  • Cleaned up control flow logic, replacing redundant $? and set +e manipulations with graceful || true fallback patterns and more idiomatic if list; then blocks.

- Utilized native bash parameter expansion and file reading mechanisms like $(< file) instead of sub-shelling external invocations like $(cat file).

- Enforced path-safety across internal directory traversals by appending -- to cd and rm commands, insulating scripts against files/folders that might start with a hyphen.

- Restructured chmod application using find -exec ... + to batch parameter arguments, bypassing the overhead of spinning up individual process instances per matched file.

- Cleaned up control flow logic, replacing redundant $? and set +e manipulations with graceful || true fallback patterns and more idiomatic if list; then blocks.
@kevmoo kevmoo requested a review from jtmcdole as a code owner February 20, 2026 18:07
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request refactors several bash scripts to improve performance, safety, and readability. Key changes include using native bash parameter expansion and file reading, enforcing path-safety with -- in cd and rm commands, batching chmod operations with find -exec ... +, and simplifying control flow logic. Overall, these changes enhance the robustness and efficiency of the shell scripts.

@kevmoo kevmoo requested a review from a team as a code owner February 20, 2026 18:49
@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. team-ios Owned by iOS platform team labels Feb 20, 2026
@kevmoo
Copy link
Contributor Author

kevmoo commented Feb 20, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully refactors several shell scripts to improve performance and safety. Key improvements include using Bash built-ins for file reading and parameter expansion, adding -- to directory and file operations to prevent misinterpretation of filenames starting with hyphens, and optimizing find commands. The cleanup of control flow logic also makes the scripts more idiomatic and robust.

@kevmoo
Copy link
Contributor Author

kevmoo commented Feb 20, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a series of performance and safety improvements across numerous shell scripts in the repository. Key changes include replacing external command invocations like cat with more efficient shell built-ins such as $(< file), and using find ... -exec ... + to batch commands. Safety is enhanced by consistently using -- with cd and rm to handle pathnames that could be misinterpreted as options. Additionally, control flow logic has been refactored to be more robust and idiomatic, for instance by replacing set +/-e blocks with if cmd; then ... or ... || true constructs. The changes are well-executed and improve the overall quality of the scripts.

set +e
git -C "$FLUTTER_ROOT" remote get-url upstream >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
if git -C "$FLUTTER_ROOT" remote get-url upstream >/dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you really want to clean this up; set GIT_WORK_TREE="$FLUTTER_ROOT" and you can remove the -C option from all the git commands

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we'd have to set the environment, right? We wouldn't want that to leak into other bits?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set it up to be a local variable that isn't exported.


# Try to find the merge-base with master, then main.
MERGEBASE=$(git -C "$FLUTTER_ROOT" merge-base HEAD "$REMOTE/master" 2>/dev/null)
MERGEBASE=$(git -C "$FLUTTER_ROOT" merge-base HEAD "$REMOTE/master" 2>/dev/null || true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat

Copy link
Member

@jtmcdole jtmcdole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome-computer-kid-computer-lgtm

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 23, 2026
@auto-submit auto-submit bot added this pull request to the merge queue Feb 23, 2026
Merged via the queue into flutter:master with commit fbfe04e Feb 23, 2026
184 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 23, 2026
@kevmoo kevmoo deleted the script_cleanup branch February 23, 2026 18:45
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2026
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Feb 26, 2026
Roll Flutter from dad6f9d4107a to b31548feb941 (39 revisions)

flutter/flutter@dad6f9d...b31548f

2026-02-25 [email protected] [web] Fix failure on Firefox 148 (flutter/flutter#182855)
2026-02-25 [email protected] Roll Fuchsia Linux SDK from KfPgw04T0OEADLJA5... to XI0Ax7fbtYE4XKYAQ... (flutter/flutter#182887)
2026-02-25 [email protected] Use AnimationStyle curve and reverseCurve in ModalBottomSheet animation (flutter/flutter#181403)
2026-02-25 [email protected] Roll Dart SDK from fd3dce5b6a4e to 5c57e75f1102 (9 revisions) (flutter/flutter#182801)
2026-02-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (#182697)" (flutter/flutter#182879)
2026-02-25 [email protected] Make sure that an AnimatedSlide doesn't crash in 0x0 environment (flutter/flutter#181535)
2026-02-24 [email protected] Reland Standardize on Test* widgets in *_tester.dart files (flutter/flutter#182632)
2026-02-24 [email protected] docs(Path): clarify that zero-length contours are excluded from computeMetrics (flutter/flutter#180165)
2026-02-24 [email protected] Fix typo in assert message (flutter/flutter#182843)
2026-02-24 [email protected] [win32] Fix overflow in TaskRunnerWindow. (flutter/flutter#182822)
2026-02-24 [email protected] feat: Add --no-uninstall flag to flutter test for integration tests (flutter/flutter#182714)
2026-02-24 [email protected] Rename noFrequencyBasedMinification to useFrequencyBasedMinification (flutter/flutter#182684)
2026-02-24 [email protected] [Impeller] Fix fail to render pixel buffer texture on Linux (flutter/flutter#181656)
2026-02-24 [email protected] Remove FlutterFramework app migration (flutter/flutter#182100)
2026-02-24 [email protected] Roll Packages from 12b43a1 to 062c8d4 (5 revisions) (flutter/flutter#182839)
2026-02-24 [email protected] [web] Run webparagraph tests in CI (flutter/flutter#182092)
2026-02-24 [email protected] Fix a race in EmbedderTest.CanSpecifyCustomUITaskRunner (flutter/flutter#182649)
2026-02-24 [email protected] flutter_tools: Use a super-parameter in several missed cases (flutter/flutter#182581)
2026-02-24 [email protected] Replace more references to `flutter/engine` with `flutter/flutter` (flutter/flutter#182654)
2026-02-24 [email protected] Carousel: Migration from Scrollable+Viewport to CustomScrollView (flutter/flutter#182475)
2026-02-24 [email protected] Refactor impellerc_main to better organize some of its logic (flutter/flutter#182783)
2026-02-24 [email protected] Remove unused `getPluginList ` (flutter/flutter#182660)
2026-02-24 [email protected] Refactor: Remove material from ticker provider test (flutter/flutter#181697)
2026-02-24 [email protected] Roll Skia from 26eebffe12bd to f44d7db68805 (3 revisions) (flutter/flutter#182821)
2026-02-24 [email protected] refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter/flutter#182697)
2026-02-24 [email protected] Roll Skia from 7dad66aae75a to 26eebffe12bd (5 revisions) (flutter/flutter#182810)
2026-02-24 [email protected] Update roadmap for 2026 (flutter/flutter#182798)
2026-02-24 [email protected] Marks Windows tool_tests_commands_1_2 to be unflaky (flutter/flutter#179670)
2026-02-23 [email protected] [web] scroll iOS iframe text input into view (flutter/flutter#179759)
2026-02-23 [email protected] Fix textscaler clamp assertion error (flutter/flutter#181716)
2026-02-23 [email protected] Roll Skia from 9a5a3c92c336 to 7dad66aae75a (4 revisions) (flutter/flutter#182779)
2026-02-23 [email protected] Move more getters from userMessages class to the appropriate places (flutter/flutter#182656)
2026-02-23 [email protected] Manual roll Dart SDK from f8fac50475b8 to fd3dce5b6a4e (6 revisions) (flutter/flutter#182768)
2026-02-23 [email protected] Copy Flutter framework to Add to App FlutterPluginRgistrant (flutter/flutter#182523)
2026-02-23 [email protected] Add progress indicator to artifact downloads (flutter/flutter#181808)
2026-02-23 [email protected] Clarify batch release mode requirements (flutter/flutter#182228)
2026-02-23 [email protected] [web] Remove --disable-gpu from flutter chrome tests (flutter/flutter#182618)
2026-02-23 [email protected] running-apps: update running-apps to use Duration.ago() (flutter/flutter#182172)
2026-02-23 [email protected] Refactor bin/ shell scripts for better performance and safety (flutter/flutter#182674)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

...
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
…r#182674)

- Utilized native bash parameter expansion and file reading mechanisms
like `$(< file)` instead of sub-shelling external invocations like
`$(cat file)`.

- Enforced path-safety across internal directory traversals by appending
-- to cd and rm commands, insulating scripts against files/folders that
might start with a hyphen.

- Restructured chmod application using find -exec ... + to batch
parameter arguments, bypassing the overhead of spinning up individual
process instances per matched file.

- Cleaned up control flow logic, replacing redundant $? and set +e
manipulations with graceful || true fallback patterns and more idiomatic
if list; then blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. team-ios Owned by iOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants