fix: guard grep in classify.sh pipeline against no-match exit under pipefail
grep exits 1 on no match, which aborts the script under set -euo pipefail.
Wrap with { grep ... || true; } so unknown formulas fall through to default.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
367b845857
commit
2b9ebe8ac0
1 changed files with 2 additions and 1 deletions
|
|
@ -36,8 +36,9 @@ if [ -f "$policy_file" ]; then
|
||||||
# Parse: look for `formula_name = "tier"` under [tiers]
|
# Parse: look for `formula_name = "tier"` under [tiers]
|
||||||
# Escape regex metacharacters in formula name for safe grep
|
# Escape regex metacharacters in formula name for safe grep
|
||||||
escaped_formula=$(printf '%s' "$formula" | sed 's/[].[*^$\\]/\\&/g')
|
escaped_formula=$(printf '%s' "$formula" | sed 's/[].[*^$\\]/\\&/g')
|
||||||
|
# grep may find no match (exit 1); guard with || true to avoid pipefail abort
|
||||||
tier=$(sed -n '/^\[tiers\]/,/^\[/{/^\[tiers\]/d;/^\[/d;p}' "$policy_file" \
|
tier=$(sed -n '/^\[tiers\]/,/^\[/{/^\[tiers\]/d;/^\[/d;p}' "$policy_file" \
|
||||||
| grep -E "^${escaped_formula}[[:space:]]*=" \
|
| { grep -E "^${escaped_formula}[[:space:]]*=" || true; } \
|
||||||
| sed -E 's/^[^=]+=[[:space:]]*"([^"]+)".*/\1/' \
|
| sed -E 's/^[^=]+=[[:space:]]*"([^"]+)".*/\1/' \
|
||||||
| head -n1)
|
| head -n1)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue