feat(build): add shfmt tool for shell formatting#565
Open
lengau wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds shfmt-based shell formatting to the project’s developer tooling, aligning with the request in issue #531 to standardize shell script formatting across the repository.
Changes:
- Add
make format-shelland include it in the top-levelmake formataggregator. - Add an
install-shfmtMake target to help installshfmtvia common package managers. - Add a
pre-commithook configuration forshfmtviapre-commit-shfmt.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Makefile | Extends the format target to include shell formatting. |
| common.mk | Introduces format-shell and an install-shfmt helper target. |
| .pre-commit-config.yaml | Adds a shfmt hook to run via pre-commit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7a9198e to
ba0b03b
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
bepri
reviewed
Jun 17, 2026
| format-shfmt: install-shfmt ##- Format shell scripts | ||
| @# jinja2 shell script templates are mistakenly counted as "true" shell scripts due to their shebang, | ||
| @# so explicitly filter them out | ||
| git ls-files -z | xargs -0 sh -c 'for f; do case "$$f" in *.sh.j2) continue;; esac; file --mime-type -Nn -- "$$f" | grep -q shellscript && printf "%s\0" "$$f"; done' -- | xargs -0 sh -c '[ $$# -eq 0 ] || exec shfmt -w "$$@"' -- |
Member
There was a problem hiding this comment.
Why is this calculation of the files to run on so much more complex than what existed in lint-shellcheck?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement shell formatting tool (shfmt) as requested in #531.