Skip to content

Commit 058a688

Browse files
committed
🗄 [chore] prevent bash only feature in script
1 parent 8547592 commit 058a688

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: warn-bash-only-features
3+
enabled: true
4+
event: file
5+
conditions:
6+
- field: file_path
7+
operator: regex_match
8+
pattern: \.sh$
9+
---
10+
11+
⚠️ **Bash-only feature detected in a `*.sh` script**
12+
13+
`*.sh` scripts in this repo should avoid bash-only features so they stay portable to POSIX `sh`. The pattern above caught **`BASH_SOURCE`**, but it's only one example. Other bash-only constructs to avoid:
14+
15+
- `BASH_*` builtins (`BASH_SOURCE`, `BASH_VERSION`, `BASH_REMATCH`, …)
16+
- `[[ ... ]]` conditionals (use `[ ... ]`)
17+
- `<<<` here-strings
18+
- `<(...)` process substitution
19+
- `(( ... ))` arithmetic commands
20+
- bash arrays (`arr=(...)`, `${arr[@]}`)
21+
- `${var,,}` / `${var^^}` case modification
22+
- `local` (POSIX `sh` has no equivalent)
23+
24+
**Specific to `BASH_SOURCE` in `pkg/**/\*.sh`:** those scripts run from the repo root via `make`/ the`run`helper, so paths should be hardcoded as`pkg/{name}/...`(see auto-memory`feedback_script_paths.md`). Don't derive them from `BASH_SOURCE`.
25+
26+
If a script genuinely needs bash, change its shebang/extension and note why.

0 commit comments

Comments
 (0)