Skip to content

shebang_has_executable

Every file starting with #! must have +x set. Catches scripts that got their +x bit stripped by git add --chmod=-x, a tar round-trip, or a cp across filesystems.


This rule takes no kind-specific options.

Plus the common paths, level, id, and when fields. This table is generated from the JSON Schema; option types and defaults are authoritative.

Scripts with a shebang but no executable bit

Section titled “Scripts with a shebang but no executable bit”

The rule fires on this repository:

README.md
scripts/
scripts/build.py
scripts/hello.sh
scripts/plain.md
README.md
# demo
scripts/build.py
#!/usr/bin/env python3
print('x')
scripts/hello.sh
#!/bin/sh
echo hi
scripts/plain.md
no shebang

With this .alint.yml:

version: 1
rules:
- id: shebang-needs-x
kind: shebang_has_executable
paths: "scripts/**"
level: error

alint check reports:

Terminal window
--- scripts/build.py -----------------------------------------------------------
x error shebang-needs-x
shebang script is not marked executable
--- scripts/hello.sh -----------------------------------------------------------
x error shebang-needs-x
shebang script is not marked executable
Summary (2 violations):
x 2 errors
0 passing * 1 failing

A shebang script that carries the executable bit

Section titled “A shebang script that carries the executable bit”

This repository is compliant:

README.md
scripts/
scripts/hello.sh (executable)
README.md
# demo
scripts/hello.sh
#!/bin/sh
echo hi

With this .alint.yml:

version: 1
rules:
- id: shebang-needs-x
kind: shebang_has_executable
paths: "scripts/**"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.