file_shebang
First line of each file in scope must match the shebang regex. Pairs with executable_has_shebang (which checks shebang presence on +x files) — file_shebang checks shebang shape.
Default shebang: is ^#!, which only enforces presence; almost every useful config supplies a tighter regex pinning the interpreter.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
shebang | string | ^#! | Rust regex; the first line of every matched file must match. Default ^#! only enforces shebang presence. |
Plus the common paths, level, id, and when fields. This table is generated from the JSON Schema; option types and defaults are authoritative.
Example
Section titled “Example”Scripts without the required shebang
Section titled “Scripts without the required shebang”The rule fires on this repository:
scripts/scripts/hardcoded.shscripts/missing.shscripts/ok.sh#!/bin/bashecho legacyecho no shebang#!/usr/bin/env bashecho okWith this .alint.yml:
version: 1rules: - id: scripts-use-env-bash kind: file_shebang paths: "scripts/*.sh" shebang: '^#!/usr/bin/env bash$' level: erroralint check reports:
--- scripts/hardcoded.sh ------------------------------------------------------- x error scripts-use-env-bash 1:1 first line "#!/bin/bash" does not match required shebang /^#!/usr/bin/env bash$/
--- scripts/missing.sh --------------------------------------------------------- x error scripts-use-env-bash 1:1 first line "echo no shebang" does not match required shebang /^#!/usr/bin/env bash$/
Summary (2 violations): x 2 errors 0 passing * 1 failingEvery script uses the env-style shebang
Section titled “Every script uses the env-style shebang”This repository is compliant:
scripts/scripts/build.shscripts/ci.sh#!/usr/bin/env bashset -euo pipefailecho ok#!/usr/bin/env bashecho okWith this .alint.yml:
version: 1rules: - id: scripts-use-env-bash kind: file_shebang paths: "scripts/*.sh" shebang: '^#!/usr/bin/env bash$' level: erroralint check reports:
v All 1 rule(s) passed.