.آ~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}$Copyright (C) 2006-2009 John GoerzenGNU LGPL, version 2.1 or above$John Goerzen <jgoerzen@complete.org> provisionalportableSafe9:;ATPThe main type for communicating between commands. All are expected to be lazy. Writes the Channel to the given Handle. If the first parameter is True, do this in a separate thread and close the handle afterwards. ~     ~ $Copyright (C) 2006-2009 John GoerzenGNU LGPL, version 2.1 or above$John Goerzen <jgoerzen@complete.org> provisionalportableNone /9:;AT@A command that carries environment variable information with it.#This is a low-level interface; see  and ! for more convenient interfaces. (An environment variable filter function.#This is a low-level interface; see  and ! for more convenient interfaces.  Different ways to get data from . DIO () runs, throws an exception on error, and sends stdout to stdoutIO String runs, throws an exception on error, reads stdout into a buffer, and returns it as a string. Note: This output is not lazy.eIO [String] is same as IO String, but returns the results as lines. Note: this output is not lazy.}IO ExitCode runs and returns an ExitCode with the exit information. stdout is sent to stdout. Exceptions are not thrown.IO (String, ExitCode) is like IO ExitCode, but also includes a description of the last command in the pipe to have an error (or the last command, if there was no error).;IO ByteString and are similar to their String counterparts.IO (String, IO (String, ExitCode)) returns a String read lazily and an IO action that, when evaluated, finishes up the process and results in its exit status. This command returns immediately.IO (IO (String, ExitCode)) sends stdout to stdout but returns immediately. It forks off the child but does not wait for it to finish. You can use  to wait for the finish.|IO Int returns the exit code from a program directly. If a signal caused the command to be reaped, returns 128 + SIGNUM.rIO Bool returns True if the program exited normally (exit code 0, not stopped by a signal) and False otherwise.xTo address insufficient laziness, you can process anything that needs to be processed lazily within the pipeline itself.eRuns a command (or pipe of commands), with results presented in any number of different ways. A shell command is something we can invoke, pipe to, pipe from, or pipe in both directions. All commands that can be run as shell commands must define these methods.Minimum implementation is .#Some pre-defined instances include:A simple bare string, which is passed to the shell for execution. The shell will then typically expand wildcards, parse parameters, etc.A (String, [String]) tuple. The first item in the tuple gives the name of a program to run, and the second gives its arguments. The shell is never involved. This is ideal for passing filenames, since there is no security risk involving special shell characters.A Handle -> Handle -> IO ()H function, which reads from the first handle and write to the second.Various functions. These functions will accept input representing its standard input and output will go to standard output. ,Some pre-defined instance functions include:(String -> String), (String -> IO String)/, plus the same definitions for ByteStrings.([String] -> [String]), ([String] -> IO [String]) , where each String( in the list represents a single line(() -> String), (() -> IO String)9, for commands that explicitly read no input. Useful with closures. Useful when you want to avoid reading stdin because something else already is. These have the unit as part of the function because otherwise we would have conflicts with things such as bare Strings, which represent a command name.Invoke a command. Type for the environment. dResult type for shell commands. The String is the text description of the command, not its output. 'How to we handle and external command. CPipe the output of the first command into the input of the second. 9Evaluates the result codes and returns an overall status FEvaluates result codes and raises an error for any bad ones it finds. >Handle an exception derived from a program exiting abnormally =Catch an exception derived from a program exiting abnormally 7A convenience function. Refers only to the version of  that returns IO ()e. This prevents you from having to cast to it all the time when you do not care about the result of .The implementation is simply: 3runIO :: (ShellCommand a) => a -> IO () runIO = run"Another convenience function. This returns the first line of the output, with any trailing newlines or whitespace stripped off. No leading whitespace is stripped. This function will raise an exception if there is not at least one line of output. Mnemonic: runSL means "run single line".$This command exists separately from  because there is already a i instance that returns a String, though that instance returns the entirety of the output in that String. zConvenience function to wrap a child thread. Kicks off the thread, handles running the code, traps execptions, the works.cNote that if func is lazy, such as a getContents sort of thing, the exception may go uncaught here.NOTE: expects func to be lazy!ESets an environment variable, replacing an existing one if it exists.^Here's a sample ghci session to illustrate. First, let's see the defaults for some variables: ;Prelude HSH> runIO $ "echo $TERM, $LANG" xterm, en_US.UTF-8Now, let's set one: TPrelude HSH> runIO $ setenv [("TERM", "foo")] $ "echo $TERM, $LANG" foo, en_US.UTF-8Or two: wPrelude HSH> runIO $ setenv [("TERM", "foo")] $ setenv [("LANG", "de_DE.UTF-8")] $ "echo $TERM, $LANG" foo, de_DE.UTF-8&We could also do it easier, like this: mPrelude HSH> runIO $ setenv [("TERM", "foo"), ("LANG", "de_DE.UTF-8")] $ "echo $TERM, $LANG" foo, de_DE.UTF-8!It can be combined with unsetenv: \Prelude HSH> runIO $ setenv [("TERM", "foo")] $ unsetenv ["LANG"] $ "echo $TERM, $LANG" foo,And used with pipes: ePrelude HSH> runIO $ setenv [("TERM", "foo")] $ "echo $TERM, $LANG" -|- "tr a-z A-Z" FOO, EN_US.UTF-8 See also .ERemoves an environment variable if it exists; does nothing otherwise. See also %, which has a more extensive example.-An instance of  represeting a pipeline. .An instance of m for an external command. The String is split using words to the command to run, and the arguments, if any. /An instance of  for an external command. The first String is the command to run, and the list of Strings represents the arguments to the program, if any. 1The same for an IO function 3An instance of : for a pure Haskell function mapping [String] to [String]..A [String] is generated from a Handle via the & function, and the reverse occurs via .ZSo, this function is intended to operate upon lines of input and produce lines of output. >An instance of t for a pure Haskell function mapping String to String. Implement in terms of (String -> IO String) for simplicity. CvA user function that takes no input, and generates output. We will deal with it using hPutStr to send the output on. SDescription of this functionThe action to run in the thread !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRO !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRCopyright (C) 2009 John GoerzenGNU LGPL, version 2.1 or above$John Goerzen <jgoerzen@complete.org> provisionalportableNone:AT)UReturn the absolute path of the arg. Raises an error if the computation is impossible. This is a thin wrapper around System.Path.absNormPath. Unix/Linux users note: System.Path.absNormPath is known to produce odd results when a tilde expansion is requested; you might prefer gJ to this function if you know your input is free of wildcards. See https:/ github.comjgoerzenhshissues/7 for details. VThe filename part of a path WThe directory part of a path XChanges the current working directory to the given path, executes the given I/O action, then changes back to the original directory, even if the I/O action raised an exception.CThis is an alias for the MissingH function System.Path.bracketCWD. Y9Load the specified files and display them, one at a time.The special file -O means to display the input. If it is not given, no input is processed at all.-$ may be given a maximum of one time. See also Z . ZCopy data from input to output, optionally with a fixed maximum size, in bytes. Processes data using ByteStrings internally, so be aware of any possible UTF-8 conversions.You may wish to use (hSetBuffering h (BlockBuffering Nothing)8 prior to calling this function for optimal performance. See also Y, [ [Generic version of Z7; reads data from specified Channel, and ignores stdin.\|Takes input, writes it to the specified file, and does not pass it on. The return value is the empty string. See also catToBS, ] ]Like \, but opens the destination in ReadWriteMode instead of ReadOnlyMode. Due to an oddity of the Haskell IO system, this is required when writing to a named pipe (FIFO) even if you will never read from it.AThis call will BLOCK all threads on open until a reader connects. This is provided in addition to \W because you may want to cat to something that you do not have permission to read from.3This function is only available on POSIX platforms. See also \ ^Like \, but appends to the file. _2An alias for System.Directory.setCurrentDirectory.5Want to change to a user's home directory? Try this: glob "~jgoerzen" >>= cd . head See also X.`:Split a list by a given character and select the nth list. %cut ' ' 2 "foo bar baz quux" -> "bar"aBRead all input and produce no output. Discards input completely. bKSplit a list by a given character and select ranges of the resultant lists. cutR [2..4] ' ' "foo bar baz quux foobar" -> "baz quux foobar" cutR [1..1000] ' ' "foo bar baz quux foobar" -> "bar baz quux foobar" cutR [-1000..1000] ' ' "foo bar baz quux foobar" -> "foo bar baz quux foobar"BNote that too large and too small indices are essentially ignored.c2Takes a string and sends it on as standard output.)The input to this function is never read.AYou can pass this thing a String, a ByteString, or even a Handle. See also echoBS. d>Search for the regexp in the lines. Return those that match. eESearch for the regexp in the lines. Return those that do NOT match. f;Exits with the specified error code. 0 indicates no error. gKTakes a pattern. Returns a list of names that match that pattern. Handles: ~username at beginning of file to expand to user's home dir ? matches exactly one character * matches zero or more characters [list] matches any character in list [!list] matches any character not in listVThe result of a tilde expansion on a nonexistant username is to do no tilde expansion.7The tilde with no username equates to the current user.ENon-tilde expansion is done by the MissingH module System.Path.Glob. hFSearch for the string in the lines. Return those that match. Same as: 'grep needle = filter (isInfixOf needle)iESearch for the string in the lines. Return those that do NOT match. jJoin lines of a filekICreates the given directory. A value of 0o755 for mode would be typical.4An alias for System.Posix.Directory.createDirectory.:The second argument will be ignored on non-POSIX systems. lNumber each line of a file m3An alias for System.Directory.getCurrentDirectory. n8Return the destination that the given symlink points to.0An alias for System.Posix.Files.readSymbolicLink4This function is only available on POSIX platforms. oAs n-, but turns the result into an absolute path.4This function is only available on POSIX platforms. p&Reverse characters on each line (rev) qReverse words on each line &Reverse characters on each line (rev) r*Reverse lines in a String (like Unix tac).Implemented as:  tac = reverseSee w. sXTakes input, writes it to all the specified files, and passes it on. This function does NOT buffer input. See also Y. tFIFO-safe version of s.AThis call will BLOCK all threads on open until a reader connects.4This function is only available on POSIX platforms. u#Translate a character x to y, like:  tr 'e' 'f' Or, in sed, y//v(Delete specified character in a string. w4Remove duplicate lines from a file (like Unix uniq).qTakes a String representing a file or output and plugs it through lines and then nub to uniqify on a line basis. x:Double space a file; add an empty line between each line. yInverse of double x; drop all empty lines. z#Convert a string to all lower case {#Convert a string to all upper case |#Count number of lines. Like wc -l }-Count number of words in a file (like wc -w) -UVWXYZ"Maximum amount of data to transferHandle for input[Handle to read from"Maximum amount of data to transferHandle for input (ignored)\]^_`abcdefghijklmnopqrstuvwxyz{|}+UVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}+U^VXYZ[\]_`bWacfghidejz{klmnopqxyrstuv}|w-UVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}Copyright (C) 2006 John GoerzenGNU LGPL, version 2.1 or above%John Goerzen <jgoerzen@complete.org>  provisionalportableNone:AT9UVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ HSH-2.1.3-I6J53KwHpYt7l0eMvk1vOX HSH.Channel HSH.CommandHSH.ShellEquivsHSH Channelizable toChannelChannel ChanStringChanBSL ChanHandle chanAsString chanAsBSLchanAsBS chanToHandle$fChannelizableByteString$fChannelizableHandle$fChannelizableByteString0$fChannelizable[] RunResultrun PipeCommand ShellCommandfdInvoke Environment InvokeResult-|- checkResultstryECcatchECrunIOrunSLsetenvunsetenv$fShellCommandEnvironCommand $fShow(->) $fRunResultIO$fRunResultIO0$fRunResultIO1$fRunResultIO2$fRunResultIO3$fRunResultIO4$fRunResultIO5$fRunResultIO6$fRunResultIO7$fRunResultIO8$fRunResultIO9$fRunResultIO10$fRunResultIO11$fShellCommandPipeCommand$fShellCommand[]$fShellCommand(,)$fShellCommand(->)$fShellCommand(->)0$fShellCommand(->)1$fShellCommand(->)2 $fShow(->)0 $fShow(->)1 $fShow(->)2 $fShow(->)3$fShellCommand(->)3$fShellCommand(->)4$fShellCommand(->)5$fShellCommand(->)6$fShellCommand(->)7$fShellCommand(->)8$fShellCommand(->)9$fShellCommand(->)10$fShellCommand(->)11$fShellCommand(->)12$fShellCommand(->)13$fShellCommand(->)14$fShellCommand(->)15 $fShow(->)4 $fShow(->)5 $fShow(->)6 $fShow(->)7 $fShow(->)8 $fShow(->)9 $fShow(->)10 $fShow(->)11 $fShow(->)12 $fShow(->)13 $fShow(->)14 $fShow(->)15 $fShow(->)16 $fShow(->)17$fShowEnvironCommand$fShowPipeCommandabspathbasenamedirname bracketCDcatFromcatBytes catBytesFromcatTo catToFIFOappendTocdcutdiscardcutRechoegrepegrepVexitglobgrepgrepV joinLinesmkdir numberLinespwdreadlink readlinkabsrevrevWtacteeteeFIFOtrtrduniqspaceunspacelowerupperwcLwcWstr2bslbsl2strEnvironCommand EnvironFiltergenericCommandprocessResults runInHandlerbase Data.OldListlinesunlinesddremgenericStringlikeIOgenericStringlikeO printCmdSpecintermediateStringlikeResultgenericStringlikeResultfifoOpen teeBSGenericsplit splitpath