úÎ|x­0      !"#$%&'()*+,-./portable provisional$John Goerzen <jgoerzen@complete.org>&=Return the absolute path of the arg. Raises an error if the computation is impossible. The filename part of a path The directory part of a path BChanges the current working directory to the given path, executes  the given I/7O action, then changes back to the original directory,  even if the I/O action raised an exception. DThis is an alias for the MissingH function System.Path.bracketCWD. :Load the specified files and display them, one at a time. The special file -2 means to display the input. If it is not given, no input is read. Unlike the shell cat, -- may be given twice. However, if it is, you -will be forcing Haskell to buffer the input. -Note: buffering behavior here is untested. GTakes input, writes it to the specified file, and does not pass it on.  See also . Like , but appends to the file. 3An alias for System.Directory.setCurrentDirectory. Want to change to a user's home directory? Try this:   glob "~jgoerzen" >>= cd . head  See also . ;Split a list by a given character and select the nth list. ' cut ' ' 2 "foo bar baz quux" -> "bar" LSplit a list by a given character and select ranges of the resultant lists.  @ cutR [2..4] ' ' "foo bar baz quux foobar" -> "baz quux foobar" G cutR [1..1000] ' ' "foo bar baz quux foobar" -> "bar baz quux foobar" O cutR [-1000..1000] ' ' "foo bar baz quux foobar" -> "foo bar baz quux foobar" CNote that too large and too small indices are essentially ignored. 3Takes a string and sends it on as standard output. +The input to this function is never read. ?Search for the regexp in the lines. Return those that match. FSearch for the regexp in the lines. Return those that do NOT match. <Exits with the specified error code. 0 indicates no error. CTakes 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 list FThe result of a tilde expansion on a nonexistant username is to do no tilde expansion. 8The tilde with no username equates to the current user. FNon-tilde expansion is done by the MissingH module System.Path.Glob. >Search for the string in the lines. Return those that match.  Same as: ) grep needle = filter (isInfixOf needle) FSearch for the string in the lines. Return those that do NOT match. Join lines of a file JCreates the given directory. A value of 0o755 for mode would be typical. 6An alias for System.Posix.Directory.createDirectory. Number each line of a file 4An alias for System.Directory.getCurrentDirectory. 9Return the destination that the given symlink points to. 2An alias for System.Posix.Files.readSymbolicLink As /, but turns the result into an absolute path. 'Reverse characters on each line (rev) Reverse words on each line +Reverse lines in a String (like Unix tac). Implemented as:   tac = reverse See . ETakes input, writes it to all the specified files, and passes it on. !This function buffers the input.  See also . $Translate a character x to y, like:   tr 'e' 'f'  Or, in sed, y// )Delete specified character in a string. 5Remove duplicate lines from a file (like Unix uniq). rTakes a String representing a file or output and plugs it through lines and then nub to uniqify on a line basis. Double space a file !+Inverse of double space; drop empty lines -Convert a string to all upper or lower case "#Count number of lines. wc -l 0.Count number of words in a file (like wc -w) 1$  !"#$    !#"$  !"#portable provisional$John Goerzen <jgoerzen@complete.org>$ Different ways to get data from %. F IO () runs, throws an exception on error, and sends stdout to stdout A IO String runs, throws an exception on error, reads stdout into ) a buffer, and returns it as a string.  IO [String]8 is same as IO String, but returns the results as lines A IO ProcessStatus runs and returns a ProcessStatus with the exit G information. stdout is sent to stdout. Exceptions are not thrown. ? IO (String, ProcessStatus) is like IO ProcessStatus, but also B includes a description of the last command in the pipe to have 9 an error (or the last command, if there was no error) D IO Int returns the exit code from a program directly. If a signal : caused the command to be reaped, returns 128 + SIGNUM. C IO Bool returns True if the program exited normally (exit code 0, 1 not stopped by a signal) and False otherwise. %=Runs 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, Cor pipe in both directions. All commands that can be run as shell $commands must define these methods. Minimum implementation is ). )Invoke a command.  The command fd to pass to it as stdin fd to pass to it as stdout UFds to close in the child. Will not harm Fds this child needs for stdin and stdout. @Action to run post-fork in child (or in main process if it doesn't fork) bReturns an action that, when evaluated, waits for the process to finish and returns an exit code. * Result type for shell commands 2345List of Fds to possibly close List of Fds to not touch, ever +DPipe the output of the first command into the input of the second. 6;Function to use when there is nothing for the child to do 7:Evaluates the result codes and returns an overall status 8GEvaluates 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 ()/. This prevents you from having to cast to it 6all the time when you do not care about the result of %. The implementation is simply: (runIO :: (ShellCommand a) => a -> IO ()  runIO = run /JAnother convenience function. This returns the first line of the output, Nwith any trailing newlines or whitespace stripped off. No leading whitespace Mis 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 %B instance that returns a String, though that instance returns the (entirety of the output in that String. 9An instance of ( represeting a pipeline. :An instance of ( for an external command. The OString is split using words to the command to run, and the arguments, if any. ;An instance of ( for an external command. The Kfirst String is the command to run, and the list of Strings represents the #arguments to the program, if any. <The same for an IO function =An 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 ?. ISo, this function is intended to operate upon lines of input and produce lines of output. @An instance of (% for a pure Haskell function mapping CString to String. Implement in terms of (String -> IO String) for  simplicity. $%&'()*+,-./ ()&'+$%./*,- $%%&''())*+,-./portable provisional%John Goerzen <jgoerzen@complete.org> 0  !"#$%&'()*+,-./A      !"#$%&'()**+,-./0123456789:;<=>?@ABCABDEF HSH-1.2.5HSH.ShellEquivs HSH.CommandHSHabspathbasenamedirname bracketCDcatFromcatToappendTocdcutcutRechoegrepegrepVexitglobgrepgrepV joinLinesmkdir numberLinespwdreadlink readlinkabsrevrevWtacteetrtrduniqspaceunspacelowerupperwcLwcW RunResultrun PipeCommand ShellCommandfdInvoke InvokeResult-|-tryECcatchECrunIOrunSLsplit splitpathddrredirclosefds nullChildFuncprocessResults checkResults$fShellCommandPipeCommand$fShellCommand[]$fShellCommand(,)$fShellCommand(->)$fShellCommand(->)0base Data.Listlinesunlines$fShellCommand(->)1