diff --git a/CHANGES.md b/CHANGES.md
index cb8bf9706e..b0d80fd7ff 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -12,6 +12,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Added
* `FileSignature.Promised` and `JarState.Promised` to facilitate round-trip serialization for the Gradle configuration cache. ([#1945](https://github.com/diffplug/spotless/pull/1945))
+* Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031))
+
### Removed
* **BREAKING** Remove `JarState.getMavenCoordinate(String prefix)`. ([#1945](https://github.com/diffplug/spotless/pull/1945))
* **BREAKING** Replace `PipeStepPair` with `FenceStep`. ([#1954](https://github.com/diffplug/spotless/pull/1954))
diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md
index 5e7d8823b9..7ce10e1edc 100644
--- a/plugin-gradle/CHANGES.md
+++ b/plugin-gradle/CHANGES.md
@@ -6,6 +6,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
### Fixed
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
+### Added
+* Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031))
+
## [6.25.0] - 2024-01-23
### Added
* Maven / Gradle - Support for formatting Java Docs for the Palantir formatter ([#2009](https://github.com/diffplug/spotless/pull/2009))
diff --git a/plugin-gradle/README.md b/plugin-gradle/README.md
index 060b900bdc..4f2d0e6930 100644
--- a/plugin-gradle/README.md
+++ b/plugin-gradle/README.md
@@ -992,7 +992,7 @@ spotless {
```gradle
spotless {
shell {
- target 'scripts/**/*.sh' // default: '*.sh'
+ target 'scripts/**/*.sh' // default: '**/*.sh'
shfmt() // has its own section below
}
@@ -1003,11 +1003,15 @@ spotless {
[homepage](https://github.com/mvdan/sh). [changelog](https://github.com/mvdan/sh/blob/master/CHANGELOG.md).
+When formatting shell scripts via `shfmt`, configure `shfmt` settings via `.editorconfig`.
+Refer to the `shfmt` man page for `.editorconfig` settings.
+
```gradle
shfmt('3.7.0') // version is optional
// if shfmt is not on your path, you must specify its location manually
shfmt().pathToExe('/opt/homebrew/bin/shfmt')
+
// Spotless always checks the version of the shfmt it is using
// and will fail with an error if it does not match the expected version
// (whether manually specified or default). If there is a problem, Spotless
diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md
index 37cc1de12e..3e3cc975b3 100644
--- a/plugin-maven/CHANGES.md
+++ b/plugin-maven/CHANGES.md
@@ -6,6 +6,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
### Fixed
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
+### Added
+* Respect `.editorconfig` settings for formatting shell via `shfmt` ([#2031](https://github.com/diffplug/spotless/pull/2031))
+
## [2.43.0] - 2024-01-23
### Added
* Support for formatting shell scripts via [shfmt](https://github.com/mvdan/sh). ([#1998](https://github.com/diffplug/spotless/issues/1998))
diff --git a/plugin-maven/README.md b/plugin-maven/README.md
index 1063f3ad12..fbe4248b7b 100644
--- a/plugin-maven/README.md
+++ b/plugin-maven/README.md
@@ -1021,11 +1021,40 @@ Uses Jackson and YAMLFactory to pretty print objects:
```
+## Shell
+
+- `com.diffplug.spotless.maven.FormatterFactory.addStepFactory(FormatterStepFactory)` [code](./src/main/java/com/diffplug/spotless/maven/shell/Shell.java)
+
+```xml
+
+
+
+ scripts/**/*.sh
+
+
+
+
+
+```
+
+### shfmt
+
+[homepage](https://github.com/mvdan/sh). [changelog](https://github.com/mvdan/sh/blob/master/CHANGELOG.md).
+
+When formatting shell scripts via `shfmt`, configure `shfmt` settings via `.editorconfig`.
+
+```xml
+
+ 3.7.0
+ /opt/homebrew/bin/shfmt
+
+```
+
## Gherkin
- `com.diffplug.spotless.maven.FormatterFactory.addStepFactory(FormatterStepFactory)` [code](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/gherkin/Gherkin.java)
-```gradle
+```xml
diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shell.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shell.java
index 6285bfc410..0626c5ceb9 100644
--- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shell.java
+++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shell.java
@@ -15,7 +15,6 @@
*/
package com.diffplug.spotless.maven.shell;
-import java.util.Collections;
import java.util.Set;
import org.apache.maven.project.MavenProject;
@@ -30,9 +29,11 @@
* and shell-specific (e.g. {@link Shfmt}) steps.
*/
public class Shell extends FormatterFactory {
+ private static final Set DEFAULT_INCLUDES = Set.of("**/*.sh");
+
@Override
public Set defaultIncludes(MavenProject project) {
- return Collections.emptySet();
+ return DEFAULT_INCLUDES;
}
@Override
diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shfmt.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shfmt.java
index 09b83240b0..4bab77ecd6 100644
--- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shfmt.java
+++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/shell/Shfmt.java
@@ -23,7 +23,6 @@
import com.diffplug.spotless.shell.ShfmtStep;
public class Shfmt implements FormatterStepFactory {
-
@Parameter
private String version;