Skip to content

Fix ShellCheck findings in Bash CLI libraries#7

Merged
codeforester merged 2 commits intomainfrom
hpr/fix-shellcheck
Apr 15, 2026
Merged

Fix ShellCheck findings in Bash CLI libraries#7
codeforester merged 2 commits intomainfrom
hpr/fix-shellcheck

Conversation

@codeforester
Copy link
Copy Markdown
Owner

Clean up the remaining ShellCheck issues reported by CI across the Bash wrapper, shared env bootstrap, and Bash libraries.

Changes include:

  • add Bash shell directives/shebangs where ShellCheck could not infer the shell
  • export BANYAN_BASH_BOOTSTRAP_SOURCE before sourcing stdlib from bash-wrapper
  • rewrite lib_file status checks so command results are checked directly
  • quote the Git upstream ref '@{u}' in lib_git
  • replace a nameref assignment in git_get_current_branch with printf -v
  • split SCRIPT_DIR declaration and assignment in lib_std
  • avoid masked return values and unquoted exits in lib_std
  • make safe_mkdir and safe_truncate ShellCheck-friendly
  • tighten pushd/popd handling in stdlib and git helpers
  • simplify banyanenv sourced-error handling

Validation:

  • bash -n over CLI shell scripts
  • full BATS suite: 98 tests, 0 failures, 1 skipped

Clean up the remaining ShellCheck issues reported by CI across the Bash
wrapper, shared env bootstrap, and Bash libraries.

Changes include:
- add Bash shell directives/shebangs where ShellCheck could not infer the shell
- export BANYAN_BASH_BOOTSTRAP_SOURCE before sourcing stdlib from bash-wrapper
- rewrite lib_file status checks so command results are checked directly
- quote the Git upstream ref '@{u}' in lib_git
- replace a nameref assignment in git_get_current_branch with printf -v
- split __SCRIPT_DIR__ declaration and assignment in lib_std
- avoid masked return values and unquoted exits in lib_std
- make safe_mkdir and safe_truncate ShellCheck-friendly
- tighten pushd/popd handling in stdlib and git helpers
- simplify banyanenv sourced-error handling

Validation:
- bash -n over CLI shell scripts
- full BATS suite: 98 tests, 0 failures, 1 skipped
Make the stdlib BATS pseudo-TTY helper portable across macOS and
GitHub Actions Linux runners.

The TTY-related stdlib tests used BSD/macOS `script` syntax:

    script -q /dev/null <command> ...

That works locally on macOS but fails on Ubuntu GitHub Actions, where
`script` is provided by util-linux and expects the command via `-c`.

Update `run_tty_script` to:
- skip TTY tests when `script` is unavailable
- detect util-linux `script` via `script --version`
- use `script -q -e -c "<command>" /dev/null` on Linux
- keep the existing BSD/macOS invocation for local runs

This fixes CI failures for:
- `is_interactive is true when run through a tty`
- `color initialization honors tty mode when --color is passed`
- `print_tty emits output when a tty is present`

Validation:
- full BATS suite: 98 tests, 0 failures, 1 skipped
@codeforester codeforester merged commit 723e440 into main Apr 15, 2026
3 checks passed
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