The current check-executables-have-shebangs hook in pre_commit_hooks/check_executables_have_shebangs.py validates shebang existence for executables. The hook allows any viable #!/... to pass, i.e. the following are all valid:
shebang
check
#!/usr/bin/python
✅ Pass
#!/bin/bash
✅ Pass
#!/bin/env python
✅ Pass
#!/usr/bin/env python
✅ Pass
Proposed feature
Implement --require-env and --fix options that will require all shebangs to use #!/usr/bin/env .... The options should be off by default. When enabled, no shebang still fails, but an existing shebang also fails if not invoked via #!/usr/bin/env, and if --fix is enabled is re-written accordingly.
Activity
asottile commented on Sep 4, 2026
no thanks. that wouldn't match the name and at the very least would be a new hook. one which I'm not really interested in maintaining or promoting
chuckatkins commented on Sep 4, 2026
fair enough