Shell script linter with common pitfall detection
Views
5.6K
Copies
2.0K
Likes
1.1K
Comments
0
Copy rate
35.0%
Prompt
Act as a senior DevOps engineer. Write a Bash linter script that scans a shell script and reports common pitfalls.
Input script to lint: [input_script]
Lint severity threshold: [severity_threshold]
Detect at minimum these issues, with file/line number and a short fix hint:
1. Unquoted variable expansions (e.g. `rm $file` instead of `rm "$file"`)
2. Use of `[ ... ]` instead of `[[ ... ]]`
3. Parsing `ls` output (e.g. `for f in $(ls)`)
4. Missing `set -euo pipefail` at the top
5. Use of backticks instead of `$(...)`
6. `cd` without checking exit code
7. Writing to a temp file without `mktemp`
8. Deprecated `echo -e` — recommend `printf`
9. Hardcoded absolute paths under `/tmp` or `/home`
10. Pipelines without `pipefail` awareness
Severity levels: info, warn, error. Threshold filters which are printed.
Output format:
- A single `lint.sh` file that runs `bash lint.sh <script-to-lint>`
- Readable colorized terminal output (red/yellow/blue) with ANSI codes
- Final summary line with counts per severity
- Exit 0 if no errors at threshold, exit 1 otherwise
- Include 3 lines of sample output at the bottom in a comment blockCustomise this prompt
Fill in 2 variables to personalise this prompt
Preview
Act as a senior DevOps engineer. Write a Bash linter script that scans a shell script and reports common pitfalls.
Input script to lint: [input_script]
Lint severity threshold: [severity_threshold]
Detect at minimum these issues, with file/line number and a short fix hint:
1. Unquoted variable expansions (e.g. `rm $file` instead of `rm "$file"`)
2. Use of `[ ... ]` instead of `[[ ... ]]`
3. Parsing `ls` output (e.g. `for f in $(ls)`)
4. Missing `set -euo pipefail` at the top
5. Use of backticks instead of `$(...)`
6. `cd` without checking exit code
7. Writing to a temp file without `mktemp`
8. Deprecated `echo -e` — recommend `printf`
9. Hardcoded absolute paths under `/tmp` or `/home`
10. Pipelines without `pipefail` awareness
Severity levels: info, warn, error. Threshold filters which are printed.
Output format:
- A single `lint.sh` file that runs `bash lint.sh <script-to-lint>`
- Readable colorized terminal output (red/yellow/blue) with ANSI codes
- Final summary line with counts per severity
- Exit 0 if no errors at threshold, exit 1 otherwise
- Include 3 lines of sample output at the bottom in a comment block