problem hub
Read-only firstBad interpreter or CRLF script error
Inspect the shebang and line endings before rewriting scripts or changing execute permissions.
Safest first command
head -1 script.sh | cat -v
Before you run this
Expected output: A shebang line; CRLF line endings may show a trailing ^M at the end of the interpreter path.
When not to use it: Do not rewrite line endings on vendor, generated, or signed files until you know the file owner and deployment source.
Expected output example
#!/bin/bash^M
How to read the result
A `^M` at the end of the shebang means the kernel may look for `/bin/bash `, causing bad interpreter errors.
What to check next
Shebang ends with ^M
Means: The script likely has Windows CRLF line endings.
Next step: Confirm file type and CRLF locations before conversion.
file reports CRLF terminators
Means: Line endings are probably the cause.
Next step: Inspect scope before converting.
No CRLF found
Means: The interpreter path, executable bit, or mount options may be wrong instead.
Next step: Check permissions and interpreter path.
Bad interpreter decision tree
Read the first line, confirm line endings, then decide whether conversion is safe. A chmod fix will not repair a shebang that points at an interpreter name with a hidden carriage return.
head -1 script.sh | cat -vfile script.shgrep -n $'\r' script.sh | head
Bad fixes to avoid
Do not chmod recursively. Do not rewrite every script in a repository without checking generated files, vendored files, and version-control state.
Common causes
- CRLF line endings copied from Windows
- Wrong interpreter path
- Script not executable
- Mounted filesystem blocks execution
What not to change yet
- Do not run dos2unix across a tree without review.
- Do not chmod -R to fix one script.
- Do not edit package-managed scripts in place before checking the package owner.
Stop and escalate if
- The next step could interrupt users, remove data, or lock out access.
- The output includes secrets, customer data, or private infrastructure details.
- You cannot explain the blast radius of the repair command.
supporting commands
Command path
Guides and drills
- Permission denied hub Use when the script path or execute bit is the actual blocker.