Skip to content

Shell scripts

Index

shell_scripts::has_shell_shebang

Return true if the given file's first line contains a bash, sh, or bats shebang. bats is included because shfmt and shellcheck both auto-detect it from the shebang and apply their bats-aware dialect.

Arguments

  • $1 (file): path

Exit codes

  • 0: if true
  • 1: if false

shell_scripts::assert_paths_exist

Die if any of the given paths does not exist on disk.

Arguments

  • ... (paths): to validate

shell_scripts::find

Emit shell-script paths under SCRIPTS_DIR when called with no args; excludes /other/ (third-party copies), /.shdoc/ (vendored shdoc submodule), and /test/bats/, /test/test_helper/bats-support/, /test/test_helper/bats-assert/ (vendored BATS submodules). With args: each arg is either a directory (recursed via shfmt --find) or a file (emitted as-is). Caller must validate that each arg exists before calling. Output: stdout — shell script file paths, one per line

Arguments

  • ... (files): or directories to search (optional; defaults to all scripts under SCRIPTS_DIR)

shell_scripts::filter

Filter candidate paths down to processable shell scripts: - Files without a bash/sh shebang are warned and skipped. - Files under /other/ require interactive confirmation (prompt::ny). Output goes into a caller-provided array via nameref so prompts can run in the caller's shell (avoids capturing prompt output in process subs).

$2..$N = candidate paths

Arguments

  • $1 (name): of output array (will be cleared and populated)

shell_scripts::find_root_only

Emit shell-script paths that live directly in SCRIPTS_DIR (no subdirectories). Used by .ci/build-docs and .ci/check-shdoc-headers to enumerate project-root executables such as format-scripts, shellcheck-scripts, check-scripts, run-install-scripts, run-set-up-scripts, run-tests. Filters to files whose first line contains a bash/sh/bats shebang (via shell_scripts::has_shell_shebang). Excludes the root-level functions.bash loader, which is a sourced library file rather than a top-level executable.

Function has no arguments.

Output on stdout

  • file paths, one per line