You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] [ / test panics when a binary operator is the last argument ([ x = ]) #321
The second form is the realistic one: an unquoted variable that is empty leaves the operator as the last argument.
Expected Behavior
Same as bash: an error on stderr, status 2, and the script continues.
bash: line 1: [: x: unary operator expected
rc=2
Actual Behavior
The process panics and exits 101. Nothing after the [ runs.
thread 'main' panicked at src/builtins/test.rs:97:22:
index out of bounds: the len is 2 but the index is 2
Additional Context
Found while reviewing #320. It is not caused by that PR: all three commands panic on main @ 9851f51. I ran debug builds only; I did not test the Python, Node.js or MCP entry points.
Possible Solution
The bounds check in src/builtins/test.rs:91 admits two remaining arguments, but the branch reads three (args[*pos + 2] at line 97):
if*pos + 2 <= args.len()
&& letSome(next) = args.get(*pos + 1)
&& is_binary_op(next){let left = &args[*pos];let op = &args[*pos + 1];let right = &args[*pos + 2];
Changing the check to *pos + 3 <= args.len() stops the panic. I have not built or tested that change, and it does not by itself give bash's status 2 for the malformed expression.
Activity
test: pin valid [ expressions that must stay quiet (strands-agents#321 …
test: pin [ ! $x -lt 3 ] with empty x as a usage error (strands-agent…