From 1574832aa72ff78f448b9bcd4304d076f4465031 Mon Sep 17 00:00:00 2001 From: Ted Kaplan Date: Thu, 31 Oct 2024 16:15:25 -0700 Subject: [PATCH] Fix shfmt config to disable Bash code simplification (#411) I'm @ormandi's colleague and was following #409. It seems the formatter wanting to remove quotes is due to Trunk by default using the `-s` flag for `shfmt` to simplify code. Either there is a bug in `shfmt` that makes it overly aggressive in removing quotes or what it's doing is actually correct, but I'm not enough of a shell expert to tell. This PR sidesteps the issue by customizes the Trunk config to avoid passing `-s`. --- .trunk/trunk.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index b501f231..2a07b173 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -44,6 +44,18 @@ lint: version_command: parse_regex: ${semver} run: buildifier --version + # Default shfmt config uses -s flag to simplify code but this can cause + # unwanted semantic changes + - name: shfmt + commands: + - name: format + output: shfmt + run: shfmt -w ${target} + success_codes: [0, 1] + cache_results: true + formatter: true + batch: true + in_place: true enabled: - actionlint@1.6.25 - buildifier@7.1.0