-
Notifications
You must be signed in to change notification settings - Fork 113
Add shell script formatter #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can you summarize the indention rules used in shfmt? |
@jserv The CI using GCC 14 on the macOS host keeps failing due to a version mismatch (the latest is gcc-15). I'll send a PR to fix it first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase the latest master
branch and squash.
af8cf25
to
10617cb
Compare
Mentioned in the commit messages. |
Move the formatting rules in |
Leverage shfmt as the standard formatter for shell scripts in this repo. - add `.editorconfig` with formatting rules and apply shfmt in .ci/check-format.sh. The formatting rules are as follows: * Use spaces for indentation * Indent with 4 spaces * Use Unix-style line endings (LF) * Remove trailing whitespace at the end of lines * Ensure the file ends with a newline * Place the opening brace of a function on the next line * Indent case statements within switch blocks * Add spaces around redirection operators (e.g., >, >>) * Place binary operators (e.g., &&, |) on the next line when breaking lines - update CONTRIBUTING.md with formatting rules and usage instructions. Contributors must ensure consistent shell script style before code submission. The early exit behavior (set -e) in .ci/check-format.sh has been removed to allow collecting all formatting mismatches in a single run. The script’s exit code is now the sum of the line-level mismatch count from clang-format-18 and the file-level mismatch count from shfmt, which should be 0 if all files are properly formatted. All existing shell scripts are reformatted with the formatting rules.
Thank @ChinYikMing for contributing. |
Leverage shfmt as the standard formatter for shell scripts in this repo.
Summary by Bito
This pull request standardizes shell script formatting by introducing shfmt, enhancing error handling, and improving readability. It includes an EditorConfig file for consistent formatting rules and updates to various scripts for better maintainability.