Apply shfmt formatting and configure MegaLinter shfmt style - #3869
#3869Apply shfmt formatting and configure MegaLinter shfmt style#3869plengauer with Copilot wants to merge 2 commits intomainplengauer/Thoth:mainfrom copilot/fix-shfmt-formatting-issuesplengauer/Thoth:copilot/fix-shfmt-formatting-issuesCopy head branch name to clipboard
Conversation
|
Hello, thanks for contributing for the first time! |
❌MegaLinter analysis: Error
Detailed Issues❌ REPOSITORY / checkov - 1 error❌ REPOSITORY / devskim - 2027 errorsNo output available ❌ REPOSITORY / grype - 2 errorsNo output available ❌ COPYPASTE / jscpd - 70 errors❌ REPOSITORY / kingfisher - 1 errorNo output available ❌ REPOSITORY / osv-scanner - 4 errors❌ REPOSITORY / trivy - 11 errorsNo output available Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts
|
- Create .mega-linter.yml with SHELL_SHFMT_ARGUMENTS="-i 2 -ci" (2-space indent,
case-indent style matching codebase conventions)
- Add SPELL_LYCHEE_FILTER_REGEX_EXCLUDE to skip lychee URL checks in .github/workflows/
- Mark demos/injection_deep_gradle/gradlew as generated in .gitattributes
- Fix #!/bin/sh -> #!/bin/bash in decorate_action.sh (uses bash-only ${!1} and $'\n')
- Run shfmt -w -i 2 -ci on all 74 shell files to apply consistent formatting
There was a problem hiding this comment.
Pull request overview
This PR standardizes shell formatting across the repo by configuring MegaLinter’s shfmt arguments to match the project’s 2-space indentation style, and then applying shfmt formatting broadly to reduce lint noise and keep diffs consistent.
Changes:
- Add MegaLinter configuration for
shfmt(-i 2 -ci) and lychee URL-scan exclusions. - Reformat a large portion of shell scripts/tests with
shfmtto match the established style. - Adjust GitHub Actions job instrumentation scripts (including a shebang change) and mark the Gradle wrapper as generated.
Reviewed changes
Copilot reviewed 45 out of 76 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| .mega-linter.yml | Adds repo-wide MegaLinter config for shfmt and lychee filtering. |
| .gitattributes | Marks demos/injection_deep_gradle/gradlew as generated for tooling. |
| INSTALL.sh | shfmt reformat; no intended logic changes. |
| meta/debian/postinst | shfmt reformat; no intended logic changes. |
| demos/injection_deep_node/demo.sh | shfmt reformat. |
| demos/_complex_download_github_releases/demo.sh | shfmt reformat (pipeline line breaks). |
| actions/instrument/shared/install.sh | shfmt reformat. |
| actions/instrument/shared/id_printer.sh | shfmt reformat. |
| actions/instrument/shared/github.sh | shfmt reformat (pipeline indentation). |
| actions/instrument/shared/config_validation.sh | shfmt reformat. |
| actions/instrument/repository/main.sh | shfmt reformat. |
| actions/instrument/checksuite/main.sh | shfmt reformat; some control-flow expanded to multi-line. |
| actions/instrument/job/inject_and_init.sh | shfmt reformat; remains bash-based script. |
| actions/instrument/job/shutdown.sh | shfmt reformat (redirection spacing). |
| actions/instrument/job/decorate_action.sh | Changes shebang to bash and shfmt reformat. |
| actions/instrument/job/decorate_action_run.sh | shfmt reformat; wrapper for shell steps. |
| actions/instrument/job/decorate_action_node.sh | shfmt reformat. |
| actions/instrument/job/decorate_action_docker.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/api.sh | shfmt reformat across API helpers. |
| src/usr/share/opentelemetry_shell/api.observe.subprocesses.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/api.observe.pipes.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/api.observe.logs.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.wget.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.shells.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.renovate.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.python.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.parallel.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.node.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.netcat.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.java.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.inner.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.github.copilot.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.github.aw.docker.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.github.actions.codeql.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.git.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.gh.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.docker.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.deep.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.curl.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.busybox.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.instrumentation.bash.sh | shfmt reformat. |
| src/usr/share/opentelemetry_shell/agent.injection.netcat.handler.sh | shfmt reformat. |
| tests/run_tests.sh | shfmt reformat; multi-line subshell/grouping for readability. |
| tests/assert.sh | shfmt reformat; expands case arms to multi-line. |
| tests/unit/test_unit_install_extract_release_version.sh | shfmt reformat (but currently introduces a syntax error). |
| tests/unit/test_unit_busybox_parses_otelapi.sh | shfmt reformat (redirection spacing). |
| tests/sdk/test_sdk_span_error.sh | Removes trailing blank line. |
| tests/sdk/test_sdk_resource_attributes.sh | shfmt reformat (test brackets spacing). |
| tests/sdk/test_sdk_observe.sh | shfmt reformat (redirection spacing). |
| tests/sdk/test_sdk_observe_pipes.sh | shfmt reformat (redirection spacing). |
| tests/performance/test_performance_script.sh | shfmt reformat (redirection spacing). |
| tests/integration/test_integration__thoth_list_node_images.sh | shfmt reformat (subshell spacing). |
| tests/integration/test_integration__renovate.sh | shfmt reformat (redirection spacing). |
| tests/integration/test_integration__philbot_stop__multi_tier_injection.sh | Removes trailing blank line. |
| tests/integration/test_integration__philbot_postinst.sh | shfmt reformat; expands inline function to multi-line. |
| tests/integration/test_integration__docker_run__node_alpine_http.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_netcat.sh | shfmt reformat (redirection spacing / case arm spacing). |
| tests/auto/test_auto_minimal_instrumentation.sh | shfmt reformat; expands inline if blocks. |
| tests/auto/test_auto_lifecycle.sh | Removes trailing blank line. |
| tests/auto/test_auto_instrument.sh | shfmt reformat; splits command list across lines. |
| tests/auto/test_auto_injection_xargs.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_injection_shebang.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_injection_python.sh | shfmt reformat (here-doc and redirection spacing). |
| tests/auto/test_auto_injection_parallel.sh | shfmt reformat (blank lines and block formatting). |
| tests/auto/test_auto_injection_node.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_injection_java.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_injection_find.sh | shfmt reformat (blank lines). |
| tests/auto/test_auto_injection_docker.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_http_injection_cleanup.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_background_job.sh | shfmt reformat (redirection spacing). |
| tests/auto/test_auto_alias.sh | shfmt reformat; expands inline if blocks. |
| tests/auto/exec.sh | shfmt reformat (redirection spacing). |
Comments suppressed due to low confidence (1)
tests/unit/test_unit_install_extract_release_version.sh:16
- Syntax error: missing command separator between
esacanddone(currentlyesac done)"). This will break the test script. Add a;(or newline) beforedone.

MegaLinter's shfmt reported formatting diffs on ~60% of shell files because no shfmt configuration existed — shfmt's tab-indent defaults conflicted with the codebase's 2-space style.
Changes
.mega-linter.yml(new): setsSHELL_SHFMT_ARGUMENTS: "-i 2 -ci"(2-space indent, indentedcasebodies) to match house style; also addsSPELL_LYCHEE_FILTER_REGEX_EXCLUDEto skip lychee URL checks on.github/workflows/.gitattributes: marksdemos/injection_deep_gradle/gradlewaslinguist-generatedto exclude the Gradle wrapper boilerplate from lintingactions/instrument/job/decorate_action.sh: fixes shebang from#!/bin/sh→#!/bin/bash— the file already used bash-only features (${!1},$'\n') that prevented shfmt from parsing it in POSIX modeshfmt -w -i 2 -ci— purely cosmetic (redirect operator spacing,casepattern alignment,;;placement)