Enum oursh::program::posix::ast::Command

source ·
pub enum Command {
    Simple(Vec<Assignment>, Vec<Word>, Vec<Redirect>),
    Compound(Vec<Command>),
    Not(Box<Command>),
    And(Box<Command>, Box<Command>),
    Or(Box<Command>, Box<Command>),
    Subshell(Box<Program>),
    Pipeline(Box<Command>, Box<Command>),
    Background(Box<Command>),
    Lang(Interpreter, String),
}
Expand description

A command is a highly mutually-recursive node with the main features of the POSIX language.

Variants§

§

Simple(Vec<Assignment>, Vec<Word>, Vec<Redirect>)

Just a single command, with it’s arguments.

Examples
date --iso-8601
§

Compound(Vec<Command>)

A full program embedded in a compound command.

{ ls ; }
§

Not(Box<Command>)

Performs boolean negation to the status code of the inner command.

Examples
! grep 'password' data.txt
§

And(Box<Command>, Box<Command>)

Perform the first command, conditionally running the next upon success.

Examples
mkdir tmp && cd tmp
§

Or(Box<Command>, Box<Command>)

Perform the first command, conditionally running the next upon failure.

Examples
kill $1 || kill -9 $1
§

Subshell(Box<Program>)

Run the inner program in a sub-shell environment.

Examples
DATE=(date)
§

Pipeline(Box<Command>, Box<Command>)

Run a command’s output through to the input of another.

Examples
cat $1 | wc -l
§

Background(Box<Command>)

Run a command in the background.

Examples
while true; do
  sleep 1; echo "ping";
done &
§

Lang(Interpreter, String)

Run a program through another parser/interpreter.

Examples
{#ruby puts (Math.sqrt(32**2/57.2))}
Compatibility

This is non-POSIX

TODO: How bad is it?

Implementations§

source§

impl Command

source

pub fn push(self, command: &Command) -> Self

source

pub fn insert(self, command: &Command) -> Self

Trait Implementations§

source§

impl Clone for Command

source§

fn clone(&self) -> Command

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Command for Command

source§

fn name(&self) -> CString

Return the name of this command. Read more
source§

impl Debug for Command

source§

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

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

impl Run for Command

source§

fn run(&self, runtime: &mut Runtime<'_>) -> Result<WaitStatus>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.