pub fn module_path_init()Expand description
Bootstrap module_path / MODULE_PATH per Src/init.c:1176:
module_path = mkarray(ztrdup(MODULE_DIR)) plus the matching
PM_TIED scalar from Src/params.c:404 IPDEF8.
MODULE_DIR is a build-time #define from Src/zshpaths.h
(e.g. /opt/homebrew/Cellar/zsh/5.9.1/lib) resolved during
zsh’s ./configure. zshrs ships modules statically linked so
there is no equivalent build-time anchor. Probe the running
system’s zsh once (cached via OnceLock) so ${module_path[1]}
/ ${(j.:.)module_path} / ${#module_path} agree between
zshrs --zsh and the system zsh that parity tests compare
against. Falls back to an empty array when no system zsh is
installed (this also makes paramtab carry an empty
module_path array rather than no entry at all, matching the
mkarray(NULL) shape the C code produces for an empty
MODULE_DIR build).
Called from setupvals (the canonical c:1014 entry point) and
from ShellExecutor::new (the bin entry that skips full
setupvals per the init_bltinmods comment at vm_helper.rs).
Extension — no direct C analog. The C source inlines this
at Src/init.c:1176 inside setupvals. Allowlisted in
tests/data/fake_fn_allowlist.txt so ShellExecutor can call
just the module_path-init subset of setupvals without invoking
the full body (which would conflict with the bin entry’s
piecewise paramtab init).