awk's empty for(;;) condition evaluates as false, so the loop body never runs.
$ awk 'BEGIN{n=0; for(;;){n++; if(n>3) break}; print n}'
0 # gawk on the same machine prints 4
$ awk 'BEGIN{for(;;){x=x+1}}'
# exit 0, empty stderr, 0 ms
In awk, an omitted for condition means true — for(;;) is the idiomatic infinite loop, exited with
break. JustBash treats the missing condition as false and skips the body entirely, so any loop written
that way is silently a no-op and whatever it was meant to compute never happens.
Note the failure mode: exit 0, no diagnostic, wrong answer. for(;;) is common enough in awk one-liners
that an agent writing one gets a confidently wrong result.
The bounded variant is fine — for(i=0;i>=0;i++) runs and is correctly stopped by the wall clock at
~1002 ms — so this is specific to the empty-condition form, not to for generally. Check while() and
do-while for the same treatment of an absent or empty condition.
Likely in lib/just_bash/commands/awk/evaluator.ex around the for clause at :590.
Pre-existing. Verified byte-identical at 16c85b3 and afe0aa8. It terminates, so it is a correctness
bug rather than a sandbox-termination hole, which is why it was left out of #69.
Found by an independent verification pass while working #69 (PR #73).
awk's emptyfor(;;)condition evaluates as false, so the loop body never runs.In awk, an omitted
forcondition means true —for(;;)is the idiomatic infinite loop, exited withbreak. JustBash treats the missing condition as false and skips the body entirely, so any loop writtenthat way is silently a no-op and whatever it was meant to compute never happens.
Note the failure mode: exit 0, no diagnostic, wrong answer.
for(;;)is common enough in awk one-linersthat an agent writing one gets a confidently wrong result.
The bounded variant is fine —
for(i=0;i>=0;i++)runs and is correctly stopped by the wall clock at~1002 ms — so this is specific to the empty-condition form, not to
forgenerally. Checkwhile()anddo-whilefor the same treatment of an absent or empty condition.Likely in
lib/just_bash/commands/awk/evaluator.exaround theforclause at :590.Pre-existing. Verified byte-identical at
16c85b3andafe0aa8. It terminates, so it is a correctnessbug rather than a sandbox-termination hole, which is why it was left out of #69.
Found by an independent verification pass while working #69 (PR #73).