bash-0.1.5: Bash generation library.

Safe HaskellNone

Language.Bash

Description

Types and functions for generation of Bash scripts, with safe escaping and composition of a large subset of Bash statements and expressions.

This module is meant to be imported qualified -- perhaps as Bash -- and contains everything you need to build and render Bash scripts. For examples of usage, look at Language.Bash.Lib.

Synopsis

Documentation

data Annotated t Source

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

Constructors

Annotated 

Fields

annotation :: t
 
statement :: Statement t
 

Instances

literal :: ByteString -> Expression tSource

Escape a ByteString to produce a literal expression.

data Identifier Source

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

identifier :: ByteString -> Maybe IdentifierSource

Produce an Identifier from a ByteString of legal format.

data SpecialVar Source

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

data Redirection Source

Redirection "directions".

Constructors

In

Input redirection, <.

Out

Output redirection, >.

Append

Appending output, >>.

newtype FileDescriptor Source

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

Constructors

FileDescriptor Word8 

class PP t whereSource

Methods

pp :: t -> State PPState ()Source

builder :: PP t => t -> BuilderSource

data PPState Source

State of pretty printing -- string being built, indent levels, present column, brace nesting.

Instances

render :: PPState -> State PPState () -> BuilderSource

Produce a builder from a pretty printer state computation.

nlCol :: Word -> PPStateSource

Pretty printer state starting on a new line indented to the given column.

script :: Annotation t => Statement t -> BuilderSource

Produce a script beginning with #!/bin/bash and a safe set statement.

script_sha1 :: forall t t'. (Annotation t, Annotation t') => ByteString -> Statement t -> Statement t' -> BuilderSource

Produce a script beginning with #!/bin/bash and some (optional) documentation. Cause the script to be scanned for SHA-1 hash of the setup (first statement argument) and main (second statement argument) before running the safe set statement and running the second argument.