Fix: Remove ternary operators causing syntax errors

Issue: Bash arithmetic expansion does not support ternary operators
Lines 1789-1791 used: base_risk=$((base_risk < 2 ? base_risk : base_risk - 1))
This caused syntax error: "error token is..."

Fix: Replace ternary operators with proper conditional logic:
- [ "$has_tty" -eq 1 ] && [ "$base_risk" -gt 1 ] && base_risk=$((base_risk - 1))

This achieves the same result (prevent risk from going below 1) without
using unsupported ternary syntax.

Testing:
✓ Syntax validation passed
✓ Script runs without errors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-02-03 19:56:12 -05:00
parent 628b5dd8ad
commit 0be6dbe551
+3 -3
View File
@@ -1786,9 +1786,9 @@ check_recent_password_changes() {
local base_risk=5
[ "$admin_active" -eq 1 ] && base_risk=2
[ "$safe_window" -eq 1 ] && base_risk=2
[ "$has_tty" -eq 1 ] && base_risk=$((base_risk < 2 ? base_risk : base_risk - 1))
[ "$login_recent" -eq 1 ] && base_risk=$((base_risk < 2 ? base_risk : base_risk - 1))
[ "$in_maintenance" -eq 1 ] && base_risk=$((base_risk < 2 ? base_risk : base_risk - 1))
[ "$has_tty" -eq 1 ] && [ "$base_risk" -gt 1 ] && base_risk=$((base_risk - 1))
[ "$login_recent" -eq 1 ] && [ "$base_risk" -gt 1 ] && base_risk=$((base_risk - 1))
[ "$in_maintenance" -eq 1 ] && [ "$base_risk" -gt 1 ] && base_risk=$((base_risk - 1))
risk=$((risk + base_risk))
details="${details}Single-user:$filtered_users "
else