bash-0.1.8: Bash generation library.

Safe HaskellNone



Bash statements and expressions. The statement tree is a functor, supporting arbitrary annotations; this is intended to support analysis of effects and privilege levels as well as commenting and arbitrary code inclusion.



data Annotated t Source

The Annotated type captures the annotatedness of a tree of Bash statements. It is Foldable and a Functor.




annotation :: t
statement :: Statement t


literal :: ByteString -> Expression tSource

Escape a ByteString to produce a literal expression.

newtype Identifier Source

The type of legal Bash identifiers, strings beginning with letters or _ and containing letters, _ and digits.


Identifier ByteString 

identifier :: ByteString -> Maybe IdentifierSource

Produce an Identifier from a ByteString of legal format.

data FuncName Source

Bash functions can have surprising names. Once the word containing the name of the function has been identified by the Bash parser, the only constraint as of this writing is that it not be all digits and contain neither quotes nor dollar signs. Thus the following are all callable functions:

  function { curl -sSfL"$1" ;}
  function 123.0 { echo 123.0 ;}
  function + { echo "$@" | sed 's/ / + /g' | bc ;}

Yet a function name may only be parsed if its surroundings constitute a valid function declaration. So we are not able to declare these functions:

  function par()ens { echo '(' "$@" ')' ;}
  function (parens) { echo '(' "$@" ')' ;}

(The parser thinks the parens are there to separate the function name from the function body.)

Some functions can be declared but not called. For example:

  function for { echo for ;}
  function x=y { echo x is y ;}

Calling the former results in a syntax error. A call to the latter is parsed as an assignment.

It is possible to override important builtins with function declarations. For example:

  function set { echo Haha! ;}
  function declare { echo Surprise! ;}

Overall, Bash function names are quite flexible but inconsistent and potentially a cause of grave errors.

funcName :: ByteString -> Maybe FuncNameSource

Produce a FuncName, choosing the Simple constructor if the name is a simple identifier.

data SpecialVar Source

The names of special variables, with otherwise illegal identifiers, are represented by this type.

newtype FileDescriptor Source

A file descriptor in Bash is simply a number between 0 and 255.


FileDescriptor Word8 

data Redirection Source

Redirection "directions".



Input redirection, <.


Output redirection, >.


Appending output, >>.