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

Safe HaskellSafe-Inferred

Language.Bash.Word

Contents

Description

Bash words and substitutions.

Synopsis

Words

type Word = [Span]Source

A Bash word, broken up into logical spans.

data Span Source

An individual unit of a word.

Constructors

Char Char

A normal character.

Escape Char

An escaped character.

Single Word

A single-quoted string.

Double Word

A double-quoted string.

ANSIC Word

A ANSI C string.

Locale Word

A locale-translated string.

Backquote Word

A backquote-style command substitution. To extract the command string, unquote the word inside.

ParamSubst ParamSubst

A parameter substitution.

ArithSubst String

An arithmetic substitution.

CommandSubst String

A command substitution.

ProcessSubst ProcessSubstOp String

A process substitution.

Parameters

data Parameter Source

A parameter name an optional subscript.

Constructors

Parameter String (Maybe Word) 

data ParamSubst Source

A parameter substitution.

Constructors

Bare 

Fields

parameter :: Parameter

The parameter to substitute.

Brace 

Fields

indirect :: Bool

Use indirect expansion.

parameter :: Parameter

The parameter to substitute.

Alt 

Fields

indirect :: Bool

Use indirect expansion.

parameter :: Parameter

The parameter to substitute.

testNull :: Bool

Test for both existence and null values.

altOp :: AltOp

The operator.

altWord :: Word

The alternate word.

Substring 

Fields

indirect :: Bool

Use indirect expansion.

parameter :: Parameter

The parameter to substitute.

subOffset :: Word

The substring offset.

subLength :: Word

The substring length, if any.

Prefix 

Fields

prefix :: String

The variable prefix.

modifier :: Char

Either @ of *.

Indices 

Fields

parameter :: Parameter

The parameter to substitute.

Length 

Fields

parameter :: Parameter

The parameter to substitute.

Delete 

Fields

indirect :: Bool

Use indirect expansion.

parameter :: Parameter

The parameter to substitute.

longest :: Bool

Replace the longest match instead of the shortest match.

deleteDirection :: Direction

Where to delete from.

pattern :: Word

The replacement pattern.

Replace 

Fields

indirect :: Bool

Use indirect expansion.

parameter :: Parameter

The parameter to substitute.

replaceAll :: Bool

Replace all occurences.

replaceDirection :: Maybe Direction

Where to replace.

pattern :: Word

The replacement pattern.

replacement :: Word

The replacement string.

LetterCase 

Fields

indirect :: Bool

Use indirect expansion.

parameter :: Parameter

The parameter to substitute.

letterCaseOp :: LetterCaseOp

Convert to lowercase, not uppercase.

convertAll :: Bool

Convert all characters, not only the starts of words.

pattern :: Word

The replacement pattern.

data AltOp Source

An alternation operator.

Constructors

AltDefault

-, :-

AltAssign

'=', :=

AltError

?, :?

AltReplace

+, :+

Process

Manipulation

fromString :: String -> WordSource

Convert a string to an unquoted word.

unquote :: Word -> StringSource

Remove all quoting characters from a word.