Skip to content

fix(shell): declare the shell — shebang where executed, directive where sourced - #335

Merged
hyperpolymath merged 2 commits into
mainfrom
fix/shellcheck-shebang-and-shell-directive
Aug 27, 2026
Merged

fix(shell): declare the shell — shebang where executed, directive where sourced#335
hyperpolymath merged 2 commits into
mainfrom
fix/shellcheck-shebang-and-shell-directive

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

shellcheck SC2148 (target shell is unknown) on 13 files here.

Deliberately not a blanket shebang. The files split by how they are used:

class count fix
executed (has +x, never sourced) 0 #!/usr/bin/env bash
sourced (referenced by source/.) 13 # shellcheck shell=bash

A sourced file is never run as its own process, so a shebang there is misleading — it claims an execution model the file does not have. The shellcheck directive states the dialect without making that false claim.

Found by an estate-wide sweep of 5,111 tracked scripts across 375 repos: 85 files lack a shell declaration. 40 were left alone deliberately — vendored duplicates (7 identical copies of one recoverer.sh) or a nested kith/ tree, and 37 of the 40 are never invoked by name anywhere, so editing them would be churn in vendored code.

Remaining SC2148 in this repo after the change: 0

…re sourced

shellcheck SC2148 ('target shell is unknown') on 13 files here.

Deliberately NOT a blanket shebang. The files split by how they are USED:

  * 0 executed (have +x, never source'd)  -> added '#!/usr/bin/env bash'
  * 13 sourced  (referenced by source/.)   -> added '# shellcheck shell=bash'

A source'd file is never run as its own process, so a shebang there is
misleading — it claims an execution model the file does not have. The
shellcheck directive states the dialect without making that false claim.

Found by an estate-wide sweep of 5,111 tracked scripts across 375 repos: 85
files lack a shell declaration. 40 of those were left alone deliberately —
they are vendored duplicates (7 identical copies of one recoverer.sh) or a
nested kith/ tree, and 37 of the 40 are never invoked by name anywhere, so
editing them would be churn in vendored code.

Remaining SC2148 in this repo after the change: 0
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6e24b371-95c7-4113-a092-fa52bc9ff51e

📥 Commits

Reviewing files that changed from the base of the PR and between 4fad80e and 53e84ef.

📒 Files selected for processing (13)
  • nick-shells/shell/baseline.sh
  • nick-shells/shell/examples/developer.sh
  • nick-shells/shell/examples/interactive.sh
  • nick-shells/shell/examples/minimal.sh
  • nick-shells/shell/modules/aliases.sh
  • nick-shells/shell/modules/behavior.sh
  • nick-shells/shell/modules/dev.sh
  • nick-shells/shell/modules/editor.sh
  • nick-shells/shell/modules/history.sh
  • nick-shells/shell/modules/locale.sh
  • nick-shells/shell/modules/path.sh
  • nick-shells/shell/modules/security.sh
  • nick-shells/shell/modules/xdg.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: rust-ci / Cargo check + clippy + fmt
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: analyze (javascript-typescript, none)
🔇 Additional comments (13)
nick-shells/shell/baseline.sh (1)

1-1: LGTM!

nick-shells/shell/examples/developer.sh (1)

1-1: LGTM!

nick-shells/shell/examples/interactive.sh (1)

1-1: LGTM!

nick-shells/shell/examples/minimal.sh (1)

1-1: LGTM!

nick-shells/shell/modules/path.sh (1)

1-1: LGTM!

nick-shells/shell/modules/security.sh (1)

1-1: LGTM!

nick-shells/shell/modules/xdg.sh (1)

1-1: LGTM!

nick-shells/shell/modules/aliases.sh (1)

1-1: LGTM!

nick-shells/shell/modules/behavior.sh (1)

1-1: LGTM!

nick-shells/shell/modules/dev.sh (1)

1-1: LGTM!

nick-shells/shell/modules/editor.sh (1)

1-1: LGTM!

nick-shells/shell/modules/history.sh (1)

1-1: LGTM!

nick-shells/shell/modules/locale.sh (1)

1-1: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Declared the Bash shell dialect across shell scripts and modules.
    • Improved static analysis accuracy and consistency.
    • No runtime behaviour or user-facing functionality has changed.

Walkthrough

The change adds # shellcheck shell=bash directives to the baseline script, shell examples, and shell modules. No runtime logic or public entities changed.

Changes

Bash ShellCheck declarations

Layer / File(s) Summary
Add Bash dialect directives
nick-shells/shell/baseline.sh, nick-shells/shell/examples/*, nick-shells/shell/modules/*
Each updated shell file declares Bash syntax for ShellCheck.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 53e84

This change only adds explicit Bash declarations to sourced shell files, with no actionable merge-blocking risk remaining after normal checks and review.

Poem

A rabbit checks each Bash-file line
With tidy notes in a neat design
No commands hop, no paths rearrange
Only linting rules now clearly change
The shell runs on, precise and fine

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main change: it distinguishes shebangs for executed files from ShellCheck directives for sourced files.
Description check ✅ Passed The description directly explains the SC2148 fix, the 13 affected sourced files, and the deliberate use of ShellCheck directives instead of shebangs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 13 files.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR resolves ShellCheck SC2148 ('target shell is unknown') across 13 shell configuration files by implementing the # shellcheck shell=bash directive for sourced modules. Codacy analysis indicates the changes are up to standards with zero new quality issues.

While the implementation correctly distinguishes between executed and sourced scripts, there is a minor documentation conflict in baseline.sh regarding POSIX compatibility. Furthermore, the PR does not include CI configuration changes to verify that these new directives are being enforced or that the reported issues are fully resolved. You should also ensure that the 40 files 'left alone' do not impact local development workflows.

About this PR

  • The PR lacks automated tests or CI configuration changes to verify that ShellCheck is running and passing with these changes. Without this, it is difficult to confirm the resolution of SC2148 across the environment.

Test suggestions

  • Verify that all 13 modified files pass ShellCheck without SC2148 errors.
  • Ensure that the added directive correctly identifies bash-specific syntax (e.g., shopt, BASH_SOURCE) during linting.
  • Verify that no execution permissions (+x) are present or added to files using the shellcheck directive instead of a shebang.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that all 13 modified files pass ShellCheck without SC2148 errors.
2. Ensure that the added directive correctly identifies bash-specific syntax (e.g., shopt, BASH_SOURCE) during linting.
3. Verify that no execution permissions (+x) are present or added to files using the shellcheck directive instead of a shebang.
Low confidence findings
  • The description mentions 40 files were 'left alone' (vendored or inactive), but these are not identified. This makes it difficult to audit if any of those files require shell declarations for local development tools.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

@@ -1,3 +1,4 @@
# shellcheck shell=bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Nitpick: The documentation on line 7 describes the script as POSIX-compatible, but the addition of the bash directive and the use of ${BASH_SOURCE[0]} on line 19 make it Bash-specific. Consider updating the description to clarify that this is a Bash configuration to avoid confusion for users of shells like dash or ash.

@hyperpolymath
hyperpolymath merged commit d480b43 into main Aug 27, 2026
19 of 20 checks passed
@hyperpolymath
hyperpolymath deleted the fix/shellcheck-shebang-and-shell-directive branch August 27, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant