͐w      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvNone24BAn arbitrary value.=Quotes a value to allow it to be safely exposed to the shell.The method used is to replace ' with '"'"' and wrap the value inside single quotes. This works for POSIX shells, as well as other shells like csh.EA value that is safely quoted so that it can be exposed to the shell.eWhile the constructor is exposed, you should avoid directly constucting Quoted values. Instead, use . wxyz{| wxyz{|None!"-234<=HKMo7This data type represents shell Arithmetic Expressions.Note that in shell arithmetic, expressions that would evaluate to a Bool, such as ANot and AEqual instead evaluate to 1 for True and 0 for False.Yif the first argument is non-zero, the result is the second, else the result is the third  shift right Rshift left (first argument's bits are shifted by the value of the second argument) $AND of the bits of the two arguments $XOR of the bits of the two arguments #OR of the bits of the two arguments}~negation jNote that this should only include things that test(1) and shell built-in test commands support portably.9Any function that takes a RedirFile can be passed a a FilePath, in which case the default file descriptor will be redirected to/from the FilePath.xOr, it can be passed a tuple of (Fd, FilePath), in which case the specified Fd will be redirected to/from the FilePath.@ZClass of values that provide a hint for the name to use for a shell variable or function.0If you don't want to provide a naming hint, use (). v1 <- T () %To provide a naming hint, use either A. v1 <- T (A "x") AUSuggests that a shell variable or function have its name contain the specified Text.CAllows modifying the value of a variable before it is passed to a command. The function is passed a Quoted Text which will expand to the value of the variable, and can modify it, by using eg . (cmd "rmdir" (WithVar name ("/home/" <>))E\The output of a command, or even a more complicated Script can be passed as a parameter to Q Examples: cmd "echo" "hello there," (Output (cmd "whoami")) cmd "echo" "root's pwent" (Output (cmd "cat" "/etc/passwd" -|- cmd "grep" "root"))G/Allows a function to take any number of Params.HCA Param is anything that can be used as the parameter of a command.rEnvironment built up by the shell script monad, so it knows which environment variables and functions are in use.IShell script monad.Specifies a redirection.use a here document as inputsame, but for input fdredirect first fd to the seconduse a file as inputappend to fileredirect the fd to a fileA shell expression.#Redirects a file handle of the Expr||&&(Piping the first Expr to the second Exprexpressions run in a sub-shell a comment a commandA shell function.JUsed for a static value.K#Used to represent a shell variable.L4A term that can be expanded in a shell command line.MTreats the Text as a glob.When used as a H> to a command, it expands to one parameter per matching file. CforCmd (cmd "ls" (glob "*/*.cabal")) $ \file -> cmd "echo" fileWhen used in a f#, it matches text against the glob.The input is assumed to be a well-formed glob. Characters in it that are not alphanumeric and are not wildcard characters will be escaped before it is exposed to the shell. This allows eg, spaces in globs.Indents an Expr+Runs the monad and generates a list of ExprIRuns the monad, and returns a list of Expr and the modified environment.bRuns the passed Script, using the current environment, and returns the list of Expr it generates.NPGenerates a shell script, including hashbang, suitable to be written to a file.!Formats an Expr to shell script.:Can generate either multiline or single line shell script.'Displays a Fd for use in a redirection.Redirections have a default Fd; for example, ">" defaults to redirecting stdout. In this case, the file descriptor number does not need to be included.]Finds an approriate marker to end a here document; the marker cannot appear inside the text.O&Generates a single line of shell code.P#Adds a shell command to the script.Q$Variadic and polymorphic version of P-A command can be passed any number of Params. odemo = script $ do cmd "echo" "hello, world" name <- newVar "name" readVar name cmd "echo" "hello" nameFor the most efficient use of Qh, add the following boilerplate, which will make string literals in your program default to being Text: {-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} import Control.Monad.Shell import qualified Data.Text.Lazy as L default (L.Text)Note that the command to run is itself a Param, so it can be a Text, or a String, or even a Var or Output. For example, this echos "hi": Odemo = script $ do echovar <- newVarContaining "echo" () cmd echovar "hi"Adds an Expr to the script.R>Adds a comment that is embedded in the generated shell script.S5Makes a Static Term from any value that can be shown.T=Defines a new shell variable, which starts out not being set.>Each call to newVar will generate a new, unique variable name.LThe namehint can influence this name, but is modified to ensure uniqueness.UDCreates a new shell variable with an initial value coming from any H. For example, packageName <- newVarFrom (Output $ cmd "grep" "-i" "name\\s*:" (glob "*.cabal") -|- cmd "perl" "-pe" "s/^name\\s*:\\s*//i") (NamedLike "packageName")Use this with C= to store to modified value of a variable in a new variable. Vhome <- globalVar "HOME" cabalDir <- newVarContaining (WithVar home (<> "/.cabal")) ()4Or to capture the output of an arithmetic operation. &sum <- newVarFrom (val x `APlus` 1) ()V]Creates a new shell variable, with an initial value which can be anything that can be shown. ds <- newVarContaining "foo bar baz" (NamedLike "s") i <- newVarContaining (1 :: Int) (NamedLike "i")W(Sets the Var to the value of the param. X9Gets a Var that refers to a global variable, such as PATHYQThis special Var expands to whatever parameters were passed to the shell script.JInside a func, it expands to whatever parameters were passed to the func. (This is $@ in shell)ZTakes the first positional parameter, removing it from positionalParameters and returning a new Var that holds the value of the parameter.QIf there are no more positional parameters, the script will crash with an error. For example: tremovefirstfile = script $ do cmd "rm" =<< takeParameter cmd "echo" "remaining parameters:" positionalParametersCreates a new shell variable, but does not ensure that it's not already set to something. For use when the caller is going to generate some shell script that is guaranteed to clobber any existing value of the variable.[Generates a new Var. Expanding this Var will yield the same result as expanding the input Var, unless it is empty, in which case it instead defaults to the expansion of the param.\Generates a new Var. If the input Var is empty, then this new Var will likewise expand to the empty string. But if not, the new Var expands to the param.]Generates a new Var. If the input Var is empty then expanding this new Var will cause an error to be thrown, using the param as the error message. If the input Var is not empty, then the new Var expands to the same thing the input Var expands to.^:Produces a Var that is a trimmed version of the input Var.aThe Quoted Text is removed from the value of the Var, either from the beginning or from the end.#If the Quoted Text was produced by Mh, it could match in multiple ways. You can choose whether to remove the shortest or the longest match.dThe act of trimming a Var is assumed to be able to produce a new Var holding a different data type._TGenerates a new Var, which expands to the length of the expansion of the input Var.[Note that 'lengthVar positionalParameters' expands to the number of positional parameters.`VDefines a shell function, and returns an action that can be run to call the function.The action is variadic; it can be passed any number of CmdParams. Typically, it will make sense to specify a more concrete type when defining the shell function.The shell function will be given a unique name, that is not used by any other shell function. The namehint can be used to influence the contents of the function name, which makes for more readable generated shell code. For example: Xdemo = script $ do hohoho <- mkHohoho hohoho (static 1) echo "And I heard him exclaim, ere he rode out of sight ..." hohoho (static 3) mkHohoho :: Script (Term Val Int -> Script ()) mkHohoho = func (NamedLike "hohoho") $ do num <- takeParameter forCmd (cmd "seq" "1" num) $ \_n -> cmd "echo" "Ho, ho, ho!" "Merry xmas!"aFRuns the command, and separates its output into parts (using the IFS)BThe action is run for each part, passed a Var containing the part.bBAs long as the first Script exits nonzero, runs the second script.cif with a Script conditional.EIf the conditional exits 0, the first action is run, else the second.dwhen with a monadic conditionale!unless with a monadic conditionalfQMatches the value of the Var against the Quoted Text (which can be generated by M?), and runs the Script action associated with the first match. sarg <- takeParameter () caseOf arg [ (quote "-h", showHelp) , (glob "-*", cmd "echo" "Unknown option:" arg) ]BCreates a block such as "do : ; cmd ; cmd" or "else : ; cmd ; cmd"The use of : ensures that the block is not empty, and allows for more regular indentation, as well as making the single line formatting work.g-Fills a variable with a line read from stdin.hBy default, shell scripts continue running past commands that exit nonzero. Use 'stopOnFailure True' to make the script stop on the first such command.i'Makes a nonzero exit status be ignored.jPipes together two Scripts.kANDs two Scripts.lORs two Scripts.m3Redirects to a file, overwriting any existing file.(For example, to shut up a noisy command: cmd "find" "/" |> "/dev/null"n?Appends to a file. (If file doesn't exist, it will be created.)o%Redirects standard input from a file.p&Redirects a script's output to stderr.q<Redirects the first file descriptor to output to the second.6For example, to redirect a command's stderr to stdout: cmd "foo" &stdError>&stdOutputr=Redirects the first file descriptor to input from the second. For example, to read from Fd 42: cmd "foo" &stdInput<&Fd 42s Helper for q and rt@Provides the Text as input to the Script, using a here-document.uDCreates a Script that checks a Test and exits true (0) or false (1).-Useful with ifCmd, whenCmd, etc; for example: *ifCmd (test (FileExists "foo")) (foo, bar)vLifts a Term to Arith. Note that , , and  cannot be used with Arith.Arith is an instance of Num, which allows you to write expressions like this with shell variables, that generate Arithmetic Expressions. val x * (100 + val y)7Allows passing an Arithmetic Expression as a parameter.6Allows passing the output of a command as a parameter.'Quoted Text arguments are passed as-is.SAllows modifying the value of a shell variable before it is passed to the command.*String arguments are automatically quoted.(Text arguments are automatically quoted.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvs  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvsINOLKJMPQHGEFAB@STUVWXYZ[\_^=?>:<;CD`abcdefjkl9mnopqrsthi]u 876543210/.-,+*)('&%$#"!v Rgt  876543210/.-,+*)('&%$#"!9:<;=?>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv      !"#$%&'()*+,-./0123456789:;<=>?@ABCCDDEEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~|}|}|}|}|}|}Hshell-monad-0.6.3Control.Monad.Shell.QuoteControl.Monad.ShellValQuotablequoteQuotedQgetQArithAIf AShiftRight AShiftLeftABitAndABitXOrABitOrAGEALEAGTALT ANotEqualAEqualAAndAOrANotAModADivAMultAMinusAPlusANegateAStaticAVarANumTestTFileExecutable TFileNonEmptyTSymlinkExistsTRegularFileExists TFileExists TDirExists TCharExists TBlockExists TFileOlder TFileNewer TFileEqualTLETGETLTTGT TNotEqualTEqual TStrNotEqual TStrEqual TNonEmptyTEmptyTOrTAndTNot RedirFile DirectionFromEnd FromBeginning Greediness LongestMatch ShortestMatch NameHinted NamedLikeWithVarOutput CmdParamsParamScriptStaticVarTermglobscript linearScriptruncmdcommentstaticnewVar newVarFromnewVarContainingsetVar globalVarpositionalParameters takeParameter defaultVarwhenVar errUnlessVartrimVar lengthVarfuncforCmdwhileCmdifCmdwhenCmd unlessCmdcaseOfreadVar stopOnFailure ignoreFailure-|--&&--||-|>|>>|<toStderr>&<&& hereDocumenttestval$fIsStringQuoted $fQuotableVal$fQuotableVal0$fQuotableVal1 $fQuotable[]$fQuotableTextghc-prim GHC.Classes>=<=></===baseGHC.ListandornotGHC.Realmod/GHC.Num*-+ Data.MonoidmappendEnv RedirSpec RedirHereDoc RedirInput RedirOutput RedirFromFileRedirToFileAppend RedirToFileExprRedirOrAndPipeSubshellCommentCmdFuncindentgen runScriptrunMfmtredirFd eofMarkeradd newVarUnsafeblock $fEnumArithGHC.EnumfromEnum enumFromToenumFromThenTo $fNumArith $fParamArith $fParamOutput $fParamQuoted$fParamWithVar $fParam[] $fParamText fromRedirFilehintedcmdAll toTextParamenvVarsenvFuncsNamedgetNameVarName UntypedVarVvarName expandVar StaticTermVarTerm simpleVargetEnv modifyEnvVarsmodifyEnvFuncsshowFdtoLinearScriptnewVarContaining'funcVarfuncVar'ifCmd'combine toSingleExpredir fileRedirmkTestfmtArith $fNumTerm$fRedirFile(,) $fRedirFile[]$fNameHintedMaybe$fNameHintedNamedLike$fNameHinted()$fCmdParamsScript$fCmdParams(->) $fParamTerm $fParamTerm0$fParamUntypedVar $fMonoidEnv $fMonadScript$fApplicativeScript $fNamedFunc$fNamedVarName$fNamedUntypedVar $fNamedTerm