pub fn getsparam(name: &str) -> Option<String>Expand description
Port of getsparam(char *s) from Src/params.c:3076.
C body:
char *getsparam(char *s) {
struct value vbuf;
Value v = getvalue(&vbuf, &s, 0);
if (!v) return NULL;
return getstrvalue(v);
}getvalue (params.c:2173) builds a Value for the parameter,
dispatching through Param.gsu->getfn for special parameters.
getstrvalue (params.c:2335) extracts the scalar form: for
PM_INTEGER calls pm->gsu.i->getfn(pm) and convbase’s the
result; for PM_SCALAR calls pm->gsu.s->getfn(pm); for
PM_ARRAY joins the elements.
Sole funnel. Every scalar parameter read in zshrs routes
through this fn — subst.rs parameter expansion AND
fusevm_bridge::expand_param both call getsparam. The
dispatch chain lives in exactly one place, mirroring C’s
“every read goes through getsparam” architecture.
Lookup order (mirrors C’s getvalue → getstrvalue cascade):
- GSU dispatch via
lookup_special_var— special parameters route through their getfn callback (uidgetfn/randomgetfn/usernamegetfn/ etc.). Same role as C’sParam.gsu->getfnvirtual dispatch. - Local variable —
variables[name]. C readspm->u.strfor PM_SCALAR; here we hold the scalar in the variables HashMap. - Environment fallback —
std::env::var(name). C imports env vars into the param table at startup so they go through the same dispatch as everything else; zshrs reads from the OS env on miss to match. - Array → scalar —
arrays[name].join(" "). Mirrors C’s PM_ARRAY case in getstrvalue (params.c:2358) which joins viasepjoin(ss, NULL, 1).
Returns None only if all four paths miss (parameter genuinely
unset).