language-bash-0.5.0: Parsing and pretty-printing Bash shell scripts

Safe HaskellSafe-Inferred

Language.Bash.Syntax

Contents

Description

Shell script types.

Synopsis

Commands

data Command Source

A Bash command with redirections.

Constructors

Command ShellCommand [Redir] 

data ShellCommand Source

A Bash command.

Constructors

SimpleCommand [Assign] [Word]

A simple command consisting of assignments followed by words.

AssignBuiltin Word [Either Assign Word]

The shell builtins declare, eval, export, local, readonly, and typeset can accept both assignments and words as arguments.

FunctionDef String List

A function name and definition.

Coproc String Command

A named coprocess.

Subshell List

A (...) list, denoting a subshell.

Group List

A {...} list.

Arith String

An arithmetic expression.

Cond (CondExpr Word)

A Bash [[...]] conditional expression.

For Word [Word] List

A for word in words command. If in words is absent, the word list defaults to "$@".

ArithFor String List

An arithmetic for ((...)) command.

Select Word [Word] List

A select word in words command. If in words is absent, the word list defaults to "$@".

Case Word [CaseClause]

A case command.

If List List (Maybe List)

An if command, with a predicate, consequent, and alternative. elif clauses are parsed as nested if statements.

Until List List

An until command.

While List List

A while command.

data CaseClause Source

A single case clause.

Constructors

CaseClause [Word] List CaseTerm 

Redirections

data Redir Source

A redirection.

Constructors

Redir

A redirection.

Fields

redirDesc :: Maybe IODesc

An optional file descriptor.

redirOp :: RedirOp

The redirection operator.

redirTarget :: Word

The redirection target.

Heredoc

A here document.

Fields

heredocOp :: HeredocOp

The here document operator.

heredocDelim :: String

The here document delimiter.

heredocDelimQuoted :: Bool

True if the delimiter was quoted.

hereDocument :: Word

The document itself, if the delimiter was quoted, no expansions are parsed. If the delimiter was not quoted, parameter, arithmetic and command substitutions take place.

data IODesc Source

A redirection file descriptor.

Constructors

IONumber Int

A file descriptor number.

IOVar String

A variable {varname} to allocate a file descriptor for.

Lists

newtype List Source

A compound list of statements.

Constructors

List [Statement] 

data Statement Source

A single statement in a list.

Constructors

Statement AndOr ListTerm 

data AndOr Source

A right-associative list of pipelines.

Constructors

Last Pipeline

The last pipeline of a list.

And Pipeline AndOr

A && construct.

Or Pipeline AndOr

A || construct.

data Pipeline Source

A (possibly timed or inverted) pipeline, linked with | or |&.

Constructors

Pipeline 

Fields

timed :: Bool

True if the pipeline is timed with time.

timedPosix :: Bool

True if the pipeline is timed with the -p flag.

inverted :: Bool

True if the pipeline is inverted with !.

commands :: [Command]

A list of commands, separated by |, or |&. command1 |& command2 is treated as a shorthand for command1 2>&1 | command2.

Assignments

data Assign Source

An assignment.

data RValue Source

The right side of an assignment.

Constructors

RValue Word

A simple word.

RArray [(Maybe Word, Word)]

An array assignment, as (subscript, word) pairs.