pub struct EofGuard<'a, 'b, S, T> { /* private fields */ }Expand description
Input decorator that prevents premature exit on EOF
This is a decorator of Input that combines the behavior of the
ignore-eof shell option with protection
against accidental exit when there are suspended jobs.
On EOF (empty line), the decorator retries reading if any of the following conditions is met (provided the shell is interactive, the input is a terminal, and the retry limit has not been reached):
SuspendedJobsGuardConfigis present inenv.any, thePosixlyCorrectoption is off, and there are suspended jobs — printsSuspendedJobsGuardConfig::message.- The
ignore-eofoption is enabled andIgnoreEofConfigis present inenv.any— printsIgnoreEofConfig::message.
The retry limit is 50 consecutive EOFs per next_line
call. Once the limit is reached the empty string is returned, allowing the
shell to exit.
If neither SuspendedJobsGuardConfig nor IgnoreEofConfig is present
in env.any, the decorator passes through all input unchanged (no retries).
Unlike IgnoreEof, this decorator also checks
for suspended jobs, so it should be used instead of IgnoreEof in the
top-level interactive read loop.
Implementations§
Source§impl<'a, 'b, S, T> EofGuard<'a, 'b, S, T>
impl<'a, 'b, S, T> EofGuard<'a, 'b, S, T>
Sourcepub fn new(inner: T, fd: Fd, env: &'a RefCell<&'b mut Env<S>>) -> Self
pub fn new(inner: T, fd: Fd, env: &'a RefCell<&'b mut Env<S>>) -> Self
Creates a new EofGuard decorator.
The arguments match those of IgnoreEof::new
except that there is no message argument — the messages are read from
SuspendedJobsGuardConfig and IgnoreEofConfig stored in env.any.
inner is the wrapped input, fd is the terminal file descriptor to
check, and env is the shared environment.
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'b, S, T> !RefUnwindSafe for EofGuard<'a, 'b, S, T>
impl<'a, 'b, S, T> !Send for EofGuard<'a, 'b, S, T>
impl<'a, 'b, S, T> !Sync for EofGuard<'a, 'b, S, T>
impl<'a, 'b, S, T> !UnwindSafe for EofGuard<'a, 'b, S, T>
impl<'a, 'b, S, T> Freeze for EofGuard<'a, 'b, S, T>where
T: Freeze,
impl<'a, 'b, S, T> Unpin for EofGuard<'a, 'b, S, T>where
T: Unpin,
impl<'a, 'b, S, T> UnsafeUnpin for EofGuard<'a, 'b, S, T>where
T: UnsafeUnpin,
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InputObject for Twhere
T: Input,
impl<T> InputObject for Twhere
T: Input,
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