pub struct LocalScope { /* private fields */ }Expand description
A parameter scope for a Rust port that is invoked as a DIRECT Rust
call rather than through dispatch_function_call.
declare_locals only stamps pm->level = locallevel; the unwind is
endparamscope’s job, and that runs from doshfunc. A port reached
by a plain Rust call (_alternative -> _tags(&…) /
_next_label(&…) -> _description(&…)) therefore never gets one, so
every name in its declare_locals list stayed shadowed for the rest
of the CALLER’s body.
Concretely: _tags declares tmp and _description declares
opts, and both names are _files’ own locals holding the results
of its zparseopts -a opts '/=tmp' 'g+:-=tmp' … W: … line. After
_alternative ran either port, _files saw opts=() / tmp=(), so
-W /dev and -g '*(-%b,-/)' were both dropped — mount /dev/<TAB>
listed every file in $PWD and PATH=…:<TAB> listed files instead
of directories.
Holding one of these for the port’s body reproduces the visible half
of what a real shell function gets from endparamscope
(Src/params.c:5867-5933, the pm->level > locallevel arm): each
declared name is put back exactly as the caller left it.
It restores by NAME rather than by bumping locallevel and calling
endparamscope, because a port’s body also writes caller-visible
state (_comp_tags, curtag, the expl array named by
_description’s $2). A whole-scope unwind takes those with it —
_tags then reported “comptags: no tags registered” for every
context.
Implementations§
Source§impl LocalScope
impl LocalScope
Sourcepub fn declare(names: &[&str], kind: u32) -> Self
pub fn declare(names: &[&str], kind: u32) -> Self
Declare names local (see declare_locals) and remember what
each one looked like beforehand.
Sourcepub fn also(&mut self, names: &[&str], kind: u32)
pub fn also(&mut self, names: &[&str], kind: u32)
Add more names to an existing scope — the port equivalent of a
second local -a … line.
Sourcepub fn also_keeping_value(&mut self, names: &[&str])
pub fn also_keeping_value(&mut self, names: &[&str])
local NAME="$NAME" — see declare_locals_keeping_value.
Trait Implementations§
Source§impl Drop for LocalScope
impl Drop for LocalScope
Auto Trait Implementations§
impl Freeze for LocalScope
impl RefUnwindSafe for LocalScope
impl Send for LocalScope
impl Sync for LocalScope
impl Unpin for LocalScope
impl UnsafeUnpin for LocalScope
impl UnwindSafe for LocalScope
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more