shell::parse

Struct ParseState

Source
struct ParseState {
    ret: ParsedJob,
    command: Option<CommandWithArgs>,
    stdio: Redirects,
    token: Option<String>,
    last_ch: char,
    current_seq: SeqType,
}

Fields§

§ret: ParsedJob§command: Option<CommandWithArgs>§stdio: Redirects§token: Option<String>§last_ch: char§current_seq: SeqType

Implementations§

Source§

impl ParseState

Source

fn new() -> Self

Source

fn command(&mut self) -> &mut CommandWithArgs

Source

fn token(&mut self) -> &mut String

Source

fn take_token(&mut self) -> String

Source

fn strip_quotes(&mut self, token: &str)

Strip single quotes and Escapes from a string and then save it as an arg. Note double quoted strings will have already been “resolved” and made single quoted by now so no need to strip double quotes.

Source

fn expand_globs(&mut self, token: &str)

Expand tokens that are file expansions (globs) into multiple arguments.

Source

fn expand_params_comms( &mut self, jobs: &mut Jobs, token: &str, ) -> Result<(), Error>

Expand tokens that contain unquoted $ chars.

Source

fn expand_tildes(&mut self, jobs: &mut Jobs, token: &str) -> Result<(), Error>

Expand ~ into home directory. TODO support other tilde expansions from https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html

Source

fn expand_braces(&mut self, jobs: &mut Jobs, token: &str) -> Result<(), Error>

Expand {..} expressions in arguments into multiple arguments. TODO Add range expressions, see https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html

Source

fn proc_token(&mut self, jobs: &mut Jobs) -> Result<(), Error>

Process a token by applying expansions and saving to argument list. TODO add process substitution and word splitting.

Source

fn end_command(&mut self, background: bool)

Source

fn pipe_or( &mut self, jobs: &mut Jobs, ch: char, next_char: char, ) -> Result<(), Error>

Source

fn seq(&mut self, jobs: &mut Jobs) -> Result<(), Error>

Source

fn and(&mut self, jobs: &mut Jobs) -> Result<(), Error>

Source

fn redir_out( &mut self, jobs: &mut Jobs, chars: &mut Peekable<Chars<'_>>, end_char: Option<char>, ) -> Result<(), Error>

Source

fn redir_in( &mut self, jobs: &mut Jobs, chars: &mut Peekable<Chars<'_>>, end_char: Option<char>, ) -> Result<(), Error>

Source

fn expand_var_or_command( &mut self, jobs: &mut Jobs, chars: &mut Peekable<Chars<'_>>, end_char: Option<char>, ) -> Result<String, Error>

Trait Implementations§

Source§

impl Debug for ParseState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ParseState> for ParsedJob

Source§

fn from(value: ParseState) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.