mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 03:49:31 +00:00
fix: always reject set -u in shell script validation hook (#2427)
The validate-file.ts hook previously only blocked `set -u` when
`set -eo pipefail` was absent from the file. This allowed scripts
with both `set -eo pipefail` and `set -u` to pass validation,
contradicting the shell rules that unconditionally ban nounset.
Fix the regex to always reject `set -u` variants on actual set
invocation lines (not comments or strings), and update the error
message to recommend `${VAR:-}` instead.
Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
This commit is contained in:
parent
73ab90fb53
commit
00aa4b2dbf
1 changed files with 5 additions and 3 deletions
|
|
@ -66,9 +66,11 @@ if (file.endsWith(".sh")) {
|
|||
fail(`echo -e detected in ${file} — use printf instead (macOS bash 3.x compat)`);
|
||||
}
|
||||
|
||||
// Check for set -u without set -eo pipefail
|
||||
if (/set\s+-.*u/.test(content) && !/set\s+-eo\s+pipefail/.test(content)) {
|
||||
fail(`set -u (nounset) detected in ${file} — use set -eo pipefail instead`);
|
||||
// Check for set -u (nounset) — always banned, even alongside set -eo pipefail.
|
||||
// Only match lines that actually invoke set (not comments or string literals).
|
||||
const setUPattern = /^\s*set\s+-[a-z]*u/m;
|
||||
if (setUPattern.test(content)) {
|
||||
fail(`set -u (nounset) detected in ${file} — use \${VAR:-} for optional vars instead`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue