Enum oursh::program::posix::ast::Command[][src]

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

Just a single command, with it’s arguments.

Examples

date --iso-8601

Tuple Fields of Simple

0: Vec<Assignment>1: Vec<Word>2: Vec<Redirect>
Compound

A full program embedded in a compound command.

{ ls ; }

Tuple Fields of Compound

0: Vec<Command>
Not

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

Examples

! grep 'password' data.txt

Tuple Fields of Not

0: Box<Command>
And

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

Examples

mkdir tmp && cd tmp

Tuple Fields of And

0: Box<Command>1: Box<Command>
Or

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

Examples

kill $1 || kill -9 $1

Tuple Fields of Or

0: Box<Command>1: Box<Command>
Subshell

Run the inner program in a sub-shell environment.

Examples

DATE=(date)

Tuple Fields of Subshell

0: Box<Program>
Pipeline

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

Examples

cat $1 | wc -l

Tuple Fields of Pipeline

0: Box<Command>1: Box<Command>
Background

Run a command in the background.

Examples

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

Tuple Fields of Background

0: Box<Command>
Lang

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?

Tuple Fields of Lang

0: Interpreter1: String

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Return the name of this command. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.