Skip to content

Commit 1574832

Browse files
authored
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`.
1 parent 28be57c commit 1574832

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.trunk/trunk.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ lint:
4444
version_command:
4545
parse_regex: ${semver}
4646
run: buildifier --version
47+
# Default shfmt config uses -s flag to simplify code but this can cause
48+
# unwanted semantic changes
49+
- name: shfmt
50+
commands:
51+
- name: format
52+
output: shfmt
53+
run: shfmt -w ${target}
54+
success_codes: [0, 1]
55+
cache_results: true
56+
formatter: true
57+
batch: true
58+
in_place: true
4759
enabled:
4860
4961

0 commit comments

Comments
 (0)