Expand description
r submodule.
Loop execution for zshrs
Port from zsh/Src/loop.c (802 lines)
§of nested loops we are in // c:33
§of continue levels // c:38
§of break levels // c:43
In C, loop.c contains execfor, execwhile, execif, execcase, execselect, execrepeat, and exectry as separate functions operating on bytecode. In Rust, all of these are implemented as match arms in ShellExecutor::execute_compound() in vm_helper, operating on the typed AST (CompoundCommand::For, While, If, Case, Select, Repeat, Try).
This module provides the loop state management and helper functions that support the executor’s loop implementation.
Statics§
- try_
errflag - Port of
mod_export zlong try_errflagfromSrc/loop.c:719. Initialized to -1 (sentinel: “no try block has fired yet in this scope”); theexectryalways-arm sets it toerrflag & ERRFLAG_ERRORbefore running the always body, then restores.TRY_BLOCK_ERRORparam (IPDEF6 atSrc/params.c:364) reads this global directly. - try_
interrupt - Port of
mod_export zlong try_interruptfromSrc/loop.c:727. Initialized to -1; mirrorstry_errflagfor theERRFLAG_INTbit.TRY_BLOCK_INTERRUPTparam reads this. - try_
tryflag - Port of
mod_export zlong try_tryflagfromSrc/loop.c:731. Depth-counter for activealways {}blocks; bumped at try entry (exectry), decremented at exit.dotrapargs(signals.c:1215) reads it to decide whether a trap’serrflagpropagates.
Functions§
- selectlist
- Select-menu display.
Port of
selectlist(LinkList l, size_t start)from Src/loop.c:347 — formats the numbered menu the C source uses forselect var in words. Picks columns automatically whencolumns == 0, mirroring the C source’s terminal-width auto-detection. WARNING: param names don’t match C — Rust=(items, start) vs C=(l, start)