From 35ebd1b65291483fded1cb939cccfe28c9116782 Mon Sep 17 00:00:00 2001 From: Tej Chajed Date: Mon, 1 Dec 2025 17:48:16 -0600 Subject: Fix shfmt when used with apheleia-formatters-respect-indent-level (#379) The shfmt formatter produced an invalid command invocation. The symptom was an error: `eval: Invalid function: "-i"` I couldn't figure out how to splice the list in correctly but `--indent=` can be passed as one argument. --------- Co-authored-by: Radon Rosborough --- CHANGELOG.md | 2 ++ apheleia-formatters.el | 14 +++++++------- test/formatters/samplecode/shfmt/out.bash | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d0c41f..46334a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog]. ### Formatters * Use clang-format for formatting Objective-C/C++ files ([#378]). * `bibtex-reformat` for BibTeX files. +### Bugs fixed +* `shfmt` did not work with `apheleia-formatters-respect-indent-level` ## 4.4.2 (released 2025-11-21) ### Bugs fixed diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 928dcbb..0cf5a93 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -206,13 +206,13 @@ (sh "posix") (t "bash")) (when apheleia-formatters-respect-indent-level - (list - "-i" (number-to-string - (cond - (indent-tabs-mode 0) - ((boundp 'sh-basic-offset) - sh-basic-offset) - (t 4))))) + (format + "--indent=%d" + (cond + (indent-tabs-mode 0) + ((boundp 'sh-basic-offset) + sh-basic-offset) + (t 4)))) "-")) (rufo . ("rufo" "--filename" filepath "--simple-exit")) (stylua . ("stylua" "-")) diff --git a/test/formatters/samplecode/shfmt/out.bash b/test/formatters/samplecode/shfmt/out.bash index 879aa94..a5903da 100644 --- a/test/formatters/samplecode/shfmt/out.bash +++ b/test/formatters/samplecode/shfmt/out.bash @@ -1,3 +1,3 @@ function f() { - thing + thing } -- cgit v1.0