Mni      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe !"#/0TGenerate command (for a shell) which corresponds to the specified program name and argument list. The program name and arguments are the usual parameters for calling an external program, like when using  runProcess or runu. The generated shell command would achieve the same effect. The name and the arguments are properly quoted, using . Note: The quoted strings are correctly recognized in shell scripts. But the shell bash has an annoying history expansion "feature", which causes it to choke on exclamation marks, when in interactive mode, even when quoted with double quotes. You can turn it off with set +o histexpand.Quote shell metacharacters.This function quotes strings, such that they are not misinterpreted by the shell. It tries to be friendly to a human reader - when special characters are present, then the string is quoted with double quotes. If not, it is left unchanged./The list of exacly which characters need to be quoted has been taken from the bash source code. Bash in turn, implements POSIX 1003.2. So the result produced should be correct. From the bash info pages: "... the rules for evaluation and quoting are taken from the POSIX 1003.2 specification for the standard Unix shell." Note: The quoted strings are correctly recognized in shell scripts. But the shell bash has an annoying history expansion "feature", which causes it to choke on exclamation marks, when in interactive mode, even when quoted with double quotes. You can turn it off with set +o histexpand.See .6Quote special characters inside a string for the shellThis quotes special characters inside a string, such that it is recognized as one string by the shell when enclosed in double quotes. Doesn't add the double quotes. Note: The quoted strings are correctly recognized in shell scripts. But the shell bash has an annoying history expansion "feature", which causes it to choke on exclamation marks, when in interactive mode, even when quoted with double quotes. You can turn it off with set +o histexpand.See , .Quote a string for the shellThis encloses a string in double quotes and quotes any special characters inside, such that it will be recognized as one string by a shell. The double quotes are added even when they aren't needed for this purpose. Note: The quoted strings are correctly recognized in shell scripts. But the shell bash has an annoying history expansion "feature", which causes it to choke on exclamation marks, when in interactive mode, even when quoted with double quotes. You can turn it off with set +o histexpand.See , .name or path of the executablecommand line arguments shell commandSafe !"#/0T&Split a path in components. Repeated "/." characters don't lead to empty components. ".]" path components are removed. If the path is absolute, the first component will start with "/". "..~" components are left intact. They can't be simply removed, because the preceding component might be a symlink. In this case, realpath is probably what you need.1The case that the path is empty is treated like ".*", yielding an empty path components list. Examples: slice_path "/" = ["/"] slice_path "/foo/bar" = ["/foo","bar"] slice_path "..//./" = [".."] slice_path "." = [] slice_path "" = []See , realpath,  realpath_s.<Form a path from path components. This isn't the inverse of , since  .  normalises the path. Cunslice_path [] = "." unslice_path cs = concat (intersperse "/" cs)See , . 4Normalise a path. This is done by reducing repeated /$ characters to one, and removing . path components. ..? path components are left intact, because of possible symlinks.Note that the normalised path isn't 100% equivalent to the original one. Any trailing slash is removed. When the last path component is a symbolic link, then both paths denote the same thing, except for in the context of the readlink call. It will fail when the trailing slash is present (because then the path denotes the directory which the link points to), but it will succeed when it is absent. *normalise_path = unslice_path . slice_pathSee , . Split a file name in components. This are the base file name and the suffixes, which are separated by dots. If the name starts with a dot, it is regarded as part of the base name. The result is a list of file name components. The filename may be a path. In this case, everything up to the last path component will be returned as part of the base file name. The path gets normalised thereby.No empty suffixes are returned. If the file name contains several consecutive dots, they are regared as part of the preceding file name component.iConcateneting the name components and adding dots, reproduces the original name, with a normalised path: concat . intersperse "." .   ==  normalise.,Note that the last path component might be "..". Then it is not possible to deduce the refered directory's name from the path. An IO action for getting the real path is then necessary. Examples: qslice_filename "a.b//./.foo.tar.gz" = ["a.b/.foo","tar","gz"] slice_filename ".x..y." = [".x.", "y."]See  , slice_filename'. This is a variant of   . It is like  z, except for being more efficient, and the filename must not contain any preceding path, since this case isn't considered.See  ,  . UForm file name from file name components, interspersing dots. This is the inverse of  ', except for normalisation of any path. +unslice_filename = concat . intersperse "."See  . Split a path in directory and file name. Only in the case that the supplied path is empty, both parts are empty strings. Otherwise, "." is filled in for the corresponding part, if necessary. Unless the path is empty, concatenating the returned path and file name components with a slash in between, makes a valid path to the file. split_pathT splits off the last path component. This isn't the same as the text after the last /.+Note that the last path component might be "..". Then it is not possible to deduce the refered directory's name from the path. Then an IO action for getting the real path is necessary. Examples: split_path "/a/b/c" == ("/a/b", "c") split_path "foo" == (".", "foo") split_path "foo/bar" == ("foo", "bar") split_path "foo/.." == ("foo", "..") split_path "." == (".", ".") split_path "" == ("", "") split_path "/foo" == ("/", "foo") split_path "foo/" == (".", "foo") split_path "foo/." == (".", "foo") split_path "foo///./bar" == ("foo", "bar") split_path "/" == ("/", ".")See .!Get the directory part of a path. dir_part = fst . split_pathSee  .&Get the last path component of a path.  filename_part = snd . split_path Examples: ?filename_part "foo/bar" == "bar" filename_part "." == "."See  . Inverse of  , except for normalisation.4This forms a path from two parts, and takes care of "."G and empty parts. When the two components are in normalised form, then  unsplit_path creates a normalised path.The definition: Gunsplit_path ("", "") = "" unsplit_path (p, q) = unsplit_parts [p, q] Examples: unsplit_path ("", "") == "" unsplit_path (".", "") == "." unsplit_path (".", ".") == "." unsplit_path ("foo", ".") == "foo"See  , , .Concatenate a list of path parts. The idea is that you can throw in reasonably formed parts, and get a reasonably formed version of the concatenated path out."."/ parts are removed. Empty parts are treated as "." parts. One leading slash in each of any but the first part is removed. The result is then interspersed with slashes and string wise concatenated. The interior of the parts isn't examined. ".."% components aren't treated specially. Examples: unsplit_parts [] == "." unsplit_parts [""] == "." unsplit_parts ["/"] == "/" unsplit_parts ["/", "foo"] == "/foo" unsplit_parts ["", "/foo"] == "foo" unsplit_parts ["/foo", "bar"] == "/foo/bar" unsplit_parts ["/foo", "/bar"] == "/foo/bar" unsplit_parts ["foo/", "bar"] == "foo//bar" unsplit_parts ["foo", "", ".", "bar"] == "foo/bar" unsplit_parts ["foo", "bar//./baz/"] == "foo/bar//./baz/"See , ,  .Split a file name in prefix and suffix. If there isn't any suffix in the file name, then return an empty suffix. A dot at the beginning or at the end is not regarded as introducing a suffix.The last path component is what is being split. This isn't the same as splitting the string at the last dot. For instance, if the file name doesn't contain any dot, dots in previous path component's aren't mistaken as introducing suffixes.:The path part is returned in normalised form. This means, "."' components are removed, and multiple "/"s are reduced to one.Note that there isn't any plausibility check performed on the suffix. If the file name doesn't have a suffix, but happens to contain a dot, then this dot is mistaken as introducing a suffix. Examples: split_filename "path/to/foo.bar" = ("path/to/foo","bar") split_filename "path/to/foo" = ("path/to/foo","") split_filename "/path.to/foo" = ("/path.to/foo","") split_filename "a///./x" = ("a/x","") split_filename "dir.suffix/./" = ("dir","suffix") split_filename "Photographie, Das 20. Jahrhundert (300 dpi)" = ("Photographie, Das 20", " Jahrhundert (300 dpi)")See , 'split_filename\'' Variant of &. This is a more efficient version of S, for the case that you know the string is is a pure file name without any slashes.See . Inverse of . Concatenate prefix and suffix, adding a dot in between, iff the suffix is not empty. The path part of the prefix is normalised.See .5Split a path in directory, base file name and suffix.:Form path from directory, base file name and suffix parts.3Test a path for a specific suffix and split it off.5If the path ends with the suffix, then the result is  Just prefix, where prefix; is the normalised path without the suffix. Otherwise it's Nothing.:Make a path absolute, using the current working directory.{This makes a relative path absolute with respect to the current working directory. An absolute path is returned unmodified.1The current working directory is determined with getCurrentDirectoryg which means that symbolic links in it are expanded and the path is normalised. This is different from pwd.Make a path absolute.sThis makes a relative path absolute with respect to a specified directory. An absolute path is returned unmodified.'The directory must be an absolute path. `absolute_path_by absdir path@('/':p) = path absolute_path_by absdir path = absdir ++ "/" ++ pathMake a path absolute.sThis makes a relative path absolute with respect to a specified directory. An absolute path is returned unmodified.CThe order of the arguments can be confusing. You should rather use . absolute_path') is included for backwards compatibility. Guess the ".."-component free form of a path, specified as a list of path components, by syntactically removing them, along with the preceding path components. This will produce erroneous results when the path contains symlinks. If the path contains leading ".." components, or more ".."; components than preceeding normal components, then the ".."B components can't be normalised away. In this case, the result is Nothing. Guess the ".."T-component free, normalised form of a path. The transformation is purely syntactic. ".." path components will be removed, along with their preceding path components. This will produce erroneous results when the path contains symlinks. If the path contains leading ".." components, or more ".."; components than preceeding normal components, then the ".."B components can't be normalised away. In this case, the result is Nothing. Bguess_dotdot = fmap unslice_path . guess_dotdot_comps . slice_path guess_dotdot "foo/../bar" = Just "bar" guess_dotdot "foo/..//bar/." = Just "bar" guess_dotdot "foo/../../bar" = Nothing guess_dotdot "../bar" = Nothing$The path to be broken to components.List of path components.List of path components7The path which consists of the supplied path components Path to be normalisedPath in normalised form Path.List of components the file name is made up of File name without path.List of components the file name is made up of List of file name components:Name of the file which consists of the supplied components Path to be splitQDirectory and file name components of the path. The directory path is normalized.Directory and file name2Path formed from the directory and file name parts"List of path parts to concatenate.*Formed path, which concatenates the parts.(Path including the file name to be split>The normalised path with the file prefix, and the file suffix.Filename to be splitBase name and the last suffixFile name prefix and suffixPath Path to split3Directory part, base file name part and suffix part3Directory part, base file name part and suffix part'Path consisting of dir, base and suffixSuffix to split off Path to testPrefix without the suffix or NothingThe path to be made absolute Absulte pathCIn case the path is relative, the directory relative to which it is/The path to be made absolute (must be absolute) Absolute pathThe path to be made absolute9The directory relative to which the path is made absolute Absolute pathList of path components+In case the path could be transformed, the ".."(-component free list of path components.Path to be normalised7In case the path could be transformed, the normalised, ".."!-component free form of the path.   Safe !"#/0T sDescribes whether an option takes an argument or not, and if so how the argument is injected into a value of type a.no argument expectedoption requires argumentoptional argumentEach  describes a single option.The arguments to  are:list of short option characters*list of long option strings (without "--")argument descriptorexplanation of option for user-What to do with options following non-options+no option processing after first non-option*freely intersperse options and non-optionswrap non-options into optionsReturn a string describing the usage of a command, derived from the header (first argument) and the options described by the second argument.pProcess the command-line, and return the list of values that matched (and those that didn't). The arguments are:The order requirements (see )The option descriptions (see ):The actual command line arguments (presumably got from ).x returns a triple, consisting of the argument values, a list of options that didn't match, and a list of error messages. None !"#/0TDBError thrown when there is an error in the command line arguments.pThe usage information is generated by the deprecated function usage_info. Better ignore this, and use the newer make_usage_info or print_usage_info.See a, b, ^. Error message KDeprecated. Usage information, as generated by the now deprecated function ^.!PThis represents the parsed contents of the command line. It is returned by the getargsL... functions, and passed on to the value extraction functions by the user.See K, L,  'getargs\'', 'getargs_ordered\''."CA property of a command line argument. These are generated by the desc_?... functions, and condensed to argument descriptions of type ArgumentDescription by argdesc. This type is abstract.%BDescription of one command line argument. These are generated by argdescJ from a list of argument properties, and subsequently used by one of the getargs... functions. 'Short option names(Long option names),What about a possible value of the argument?*3Minimum and maximum of number of occurences allowed+1Name for argument's value, for message generation,2Descrition of the argument, for message generation-Argument value tester.~Argument value tester function. This tests the format of an argument's value for errors. The tester function is specified by B. or such, as part of the argument description.SThe tester is passed the argument value. If the format is correct, then it returns Nothing(. If there is an error, then it returns  Just msgf, with msgf being an error message generation function. This function gets passed the argument description, and produces the error message. The argument description typically is used to extract a descriptive name of the argument (using F or G') to be included in the error message./-Does the command line argument take an value?0No value1Value required2Value optional3Whether the specified argument is the direct argument. Direct arguments are the ones which are specified without introducing "-" or "--", in the command line, or which occur after the special argument "--".See J, 6.4^Short name of the argument. This specifies a character for a one letter style argument, like -xu. There can be specified several for the same argument. Each argument needs at least either a short or a long name.5{Long name of the argument. This specifies a GNU style long name for the argument, which is introduced by two dashes, like --arg or  --arg=.... There can be specified several names for the same argument. Each argument needs at least either a short or a long name. Except for direct arguments, which don't have a name.See 66Signal that this is the description of direct arguments. Direct arguments are the ones not introduced by any short or long argument names (like -x or --arg). After the special argument --@, also everything is a direct argument, even when starting with - or --. The presence of  desc_direct) in the argument properties list signals argdescb that this is the description of the direct arguments. There may be at most one such description.The  is_direct[ function can be used in order to determine if a specific argument is the direct argument.See 3.7*Signal that the argument requires a value.8kSignal that the argument optionally has a value. The user may or may not specify a value to this argument.9LSpecify lower and upper bound on the number of times an argument may occur.:uSignal that the argument must be present exactly once. This is meaningful only for arguments which can take a value.;6Signal that the argument must occur at least one time.<5Signal that the argument must occur at most one time.=vSignal that the argument must have at least the specified number of occurences, and has no upper limit of occurences.>7Signal that the argument may occur any number of times.?kSignal that the argument does not need to be present, and may occur at most the specified number of times.@Specify the descriptive name for command line argument's value. Used for the generation of the usage message. The name should be very short.ASpecify a description of what the argument does. Used for usage message generation. This can be arbitratily long, long lines are wrapped.B"Specify a tester for this argument. The tester is a function which tests the argument value for format errors. Typically, it tests whether the value can be parsed to some target type. If the test fails, the tester produces an error message. When parsing the command line arguments (which getargsT or related), all the testers are applied to the respective argument values, and an  is thrown in case of failure. By using a tester, it can be ensured that the argument values abide a specific format when extracting them, such that they can be parsed without errors, e.g. &myarg = read (reqarg_req args d_myarg).)An argument tester is a function of type ..See C, D, E, ..C Build an argument tester from a readsM like function. Typically, a specialisation of the standard prelude function read is used. Example: 3readtester "Integer expected." (reads :: ReadS Int)DSpecify that the value of this argument, if present, is a positive integer. This will cause an error when the command line is parsed, and the argument's value doesn't specify an integer. Pdesc_integer = desc_tester (readtester (reads :: ReadS Int) "Integer expected.")See B.ESpecify that the value of this argument, if present, is a non-negative integer. This will cause an error when the command line is parsed, and the value doesn't specify a non-negative integer. desc_nonneg_integer = desc_tester (readtester ((filter (\(a,_) -> a >= 0) . reads) :: ReadS Int) "Non-negative integer expected." )See B.FGenerate a descriptive argument name from an argument description, suitable for use in error messages and usage information. This uses the long and short argument names (as specified by 4 and 5) and generates descriptive names of the argument like "-f", "--myflag", "-f/--myflag", etc. All the argument names are included. In case of direct arguments (see 6), the descriptive name is "(direct argument)".See J.GGenerate a descriptive argument name from an argument description, beginning with "argument". This uses the long and short argument names (as specified by 4 and 5) and generates descriptive names of the argument like "argument -f", "argument --myflag", "argument -f/--myflag", etc. All the argument names are included. In case of direct arguments (see 6-), the descriptive name is "direct argument".See J.HCreate a string, which lists the short forms of one command line argument. If it has an subargument, it's name is listed as well. For arguments without short form, the result is the empty string.For the illegal command line argument, with neither short nor long forms, and not being the direct argument either, the result is "yet unnamed argument"E. Such argument descriptions are incomplete, and will be rejected by getargs and unsafe_getargs.ZThis is meant for refering to an argument, such as in error messages or usage information. Examples: argname_short (argdesc [ desc_short 'a' , desc_short 'b' , desc_value_required , desc_argname "Name" ]) == "-a/-b Name"See J, 6. I.ICreate a string, which lists the long forms of one command line argument. If it has an subargument, it's name is listed as well. For arguments without long form, the result is the empty string.For the illegal command line argument, with neither short nor long forms, and not being the direct argument either, the result is "yet unnamed argument"E. Such argument descriptions are incomplete, and will be rejected by getargs and unsafe_getargs.ZThis is meant for refering to an argument, such as in error messages or usage information. Examples: argname_long (argdesc [ desc_long "foo" , desc_long "bar" , desc_value_required , desc_argname "Name" ]) == "--foo/--bar Name"See J, 6. I.JMake an argument description from a list of argument properties. This condenses the list to an argument description, which can be used by the getargs;... functions and the argument value extraction functions.KFParse command line arguments. The arguments are taken from a call to getArgs' and parsed. Any error is thrown as a ArgErrorj exception. The result is a value from which the information in the command line can be extracted by the arg..., reqarg... and optarg... functions.*The header is used only by the deprecated  usage_info_ function. If you don't use it, you don't need to specify a header. Just pass an empty string.Named arguments (like -x or --arg/) and direct arguments may occur in any order.See ^, a, b.LFParse command line arguments. The arguments are taken from a call to getArgs' and parsed. Any error is thrown as a ArgErrorj exception. The result is a value from which the information in the command line can be extracted by the arg..., reqarg... and optarg... functions.*The header is used only by the deprecated  usage_info_ function. If you don't use it, you don't need to specify a header. Just pass an empty string.~All arguments after the first direct argument are regarded as direct arguments. This means that argument names introduced by - or -- no longer take effect.See ^, a, b.M;Parse the specified command line. Any error is returned as Left argerror1. In case of success, the result is returned as  Right resP. From the result, the information in the command line can be extracted by the arg..., reqarg ... and optarg... functions.*The header is used only by the deprecated  usage_info_ function. If you don't use it, you don't need to specify a header. Just pass an empty string.Named arguments (like -x or --arg/) and direct arguments may occur in any order.See ^, a, b.N;Parse the specified command line. Any error is returned as Left argerror1. In case of success, the result is returned as  Right resP. From the result, the information in the command line can be extracted by the arg..., reqarg ... and optarg... functions.*The header is used only by the deprecated  usage_info_ function. If you don't use it, you don't need to specify a header. Just pass an empty string.~All arguments after the first direct argument are regarded as direct arguments. This means that argument names introduced by - or -- no longer take effect.See ^, a, b.OQuery whether a certain switch is specified on the command line. A switch is an argument which is allowed zero or one time, and has no value.P.Query the number of occurences of an argument.QQuery the values of an argument with optional value. This is for arguments which take an optional value, and may occur several times. The occurences with value are represented as  Just value-, the occurences without are represented as Nothing.RQuery the values of an argument with required value. This is for arguments which require a value, and may occur several times.SQuery the optional value of a required argument. This is for arguments which must occur once, and may have a value. If the argument is specified, its value is returned as  Just value. If it isn't, the result is Nothing.TrQuery the value of a required argument. This is for arguments which must occur exactly once, and require a value.UQuery the optional value of an optional argument. This is for arguments which may occur zero or one time, and which may or may not have a value. If the argument doesn't occur, the result is Nothing:. If it does occur, but has no value, then the result is  Just Nothing.. If it does occur with value, the result is Just (Just value).VQuery the value of an optional argument. This is for optional arguments which require a value, and may occur at most once. The result is  Just value if the argument occurs, and Nothing if it doesn't occur.W.None of the specifed arguments may be present.7Throws an ArgError if any of the arguments are present.X/All of the specified arguments must be present.%Throws an ArgError if any is missing.Y7Exactly one of the specified arguments must be present.Otherwise throw an ArgError.Z6At most one of the specified arguments may be present.Otherwise throw an ArgError.[8At least one of the specified arguments must be present.Otherwise throw an ArgError.\XWhen the specified argument is present, then none of the other arguments may be present.Otherwise throw an ArgError.]:Whether the specified argument occurs in the command line.^ DeprecatedI. This is left here for backwards compatibility. New programs should use make_usage_info and/or print_usage_info.xGet the usage information from the parsed arguments. The usage info contains the header specified to the corresponding  getargs...; function, and descriptions of the command line arguments.GDescriptions can be several lines long. Lines get wrapped at column 80.See a, b, c._getargs} as a pure function, instead of an IO action. This allows to make evaluated command line arguments global values. This calls getargs) to parse the command line arguments. GHC.IO.unsafePerformIO0 is used to take the result out of the IO monad. Gunsafe_getargs header descs = GHC.IO.unsafePerformIO $ getargs "" descsThe getargsX action is performed on demand, when the parse result is evaluated. It may result in an L being thrown. In order to avoid this happening at unexpected times, the main& function should, start with the line seq args (return ()), where args is the result of unsafe_getargs,. This will trigger any command line argument errors at the beginning of the program. (See section 6.2 of the Hakell Report for the definition of seq).*The header is used only by the deprecated  usage_infoa function. If you don't use it, you don't need to specify a header. Just pass an empty string.A typical use of unsafe_getargs looks like this: descs = [ d_myflag, ... ] d_myflag = argdesc [ ... ] args = unsafe_getargs "" descs myflag = arg_switch args d_myflag main = mainwrapper $ do seq args (return ()) ...See K, `.`getargs_orderedC as a pure function, instead of an IO action. This is exactly like unsafe_getargs , but using getargs_ordered instead of getargs.*The header is used only by the deprecated  usage_infoa function. If you don't use it, you don't need to specify a header. Just pass an empty string.The definition is: Junsafe_getargs_ordered = GHC.IO.unsafePerformIO $ getargs_ordered "" descsSee _, ^, a, b.aGenerate pretty-printed information about the command line arguments. This function gives you much control on how the usage information is generated. print_usage_info" might be more like what you need.5The specified argument descriptions (as taken by the getargs... functions) are processed in the given order. Each one is formatted as a paragraph, detailing the argument. This is done according to the specified geometry.The direct argument, in case there is one, is omitted. You should detail the direct command line arguments separatly, such as in some header.kThe specified maximum breadths must fit in the specified width, or an error is raised. This happens, when 4colsleft + colsshort + 2 + colslong + 2 + 2 > width.See b, K, ^, %, A, J, , .bqPrint the usage information (about the command line arguments), for the specified header and arguments to the specified handle. When the handle is connected to a terminal, the terminal's width (in columns) is used to format the output, such that it fits the terminal. Both the header and the argument descriptions are adapted to the width of the terminal (by using wrap).[When the handle does not connected to a terminal, 80 columns are used. This may happen to stdout or stderr\, for instance, when the program is in a pipe, or the output has been redirected to a file.lWhen the terminal is too narrow for useful output, then instead of the usage information, a short message ("Terminal too narrow"F) is printed. This applies to terminals with a width of less than 12.You should specify one long line for each paragraph in the header and the argument descriptions, and let print_usage_info do the wrapping. When you have several paragraphs, separate them by a double \n\nY. This also applies for an empty line, which should be printed after the actual header.^The arguments are printed in the order, in which they occur in the argument description list. This function is a front end to terminal_width and make_usage_info.See J, A, , a, ^, c.cPBreak down a text to lines, such that each one has the specified maximum width.vNewline characters in the input text are respected. They terminate the line, without it being filled up to the width.jThe text is wrapped at space characters. Words remain intact, except when they are too long for one line.eMake ArgError an instance of  ExceptionG, so we can throw and catch it, using GHC-6.10's new exception library.] !"#$%&'()*+,-./012     3%Argument description, as returned by argdesc.4#The character to name the argument.$The corresponding argument property.5The long name of the argument.$The corresponding argument property.67893Lower bound of the allowed number of argdesc_times.3Upper bound of the allowed number of argdesc_times.$The corresponding argument property.:$The corresponding argument property.;$The corresponding argument property.<$The corresponding argument property.=Number of times.$The corresponding argument property.>$The corresponding argument property.?Number of times.$The corresponding argument property.@Name of the argument's value.$The corresponding argument property.A"Short description of the argument.$The corresponding argument property.B)Argument tester to apply to this argument$The corresponding argument property.CDEF%Argument description, as returned by argdescPrintable name for the argumentG%Argument description, as returned by argdescPrintable name for the argumentH%Argument description, as returned by argdescPrintable name for the argumentI%Argument description, as returned by argdescPrintable name for the argumentJ=List of properties, which describe the command line argument.'The corresponding argument description.K$Header to be used by the deprecated  usage_info function.The argument descriptions.!The contents of the command line.L$Header to be used by the deprecated  usage_info function.Descriptions of the arguments.!The contents of the command line.M$Header to be used by the deprecated  usage_info function.Command line to be parsed.The argument descriptions.!The contents of the command line.N$Header to be used by the deprecated  usage_info function.Command line to be parsed.The argument descriptions.!The contents of the command line.OCommand line parse result.#Argument description of the switch.2Whether the switch is present in the command line.PCommand line parse result.Description of the argument.$Number of times the argument occurs.QCommand line parse result.Description of the argument.The occurences of the argument.RCommand line parse result.Description of the argument.The values of the argument.SCommand line parse result.Description of the argument.(The value of the argument, if it occurs.TCommand line parse result.Description of the argument.The value of the argument.UCommand line parse result.Description of the argument.8The occurence of the argument and its value (see above).VCommand line parse result.Description of the argument.(The value of the argument, if it occurs.W0List of the arguments which must not be present.Command line parse result.X,List of the arguments which must be present.Command line parse result.Y<List of the arguments, of which exactly one must be present.Command line parse result.Z;List of the arguments, of which at most one may be present.Command line parse result.[=List of the arguments, of which at least one must be present.Command line parse result.\3Argument which doesn't tolerate the other arguments:Arguments which aren't tolerated by the specified argumentCommand line parse result.]Command line parse result.'Description of the respective argument.:Whether the specified argument occurs in the command line.^_$Header to be used by the deprecated  usage_info function.The argument descriptions!The parsed command line arguments`$Header to be used by the deprecated  usage_info function.The argument descriptions!The parsed command line argumentsa/List of argument descriptions, as created by a argdesc8The output is indented this many columns. Probably zero.oMaximum width of the column of the short form of each argument. When this many aren't needed, less are used.nMaximum width of the column of the long form of each argument. When this many aren't needed, less are used.FWrap everything at this column. Should probably be the terminal width.TPretty printed usage information, in paragraphs, which contain one or several lines.b+To which handle to print the usage info.+The header to print first. Can be empty.IThe argument description of the arguments, which should be documented.cCMaximum width for the lines of the text, which is to be broken downText to break downThe broken down text in columnsdefgG !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcG"#$%&'()*+,-/012.J456789:;<>=?@ABDEC3!KLMN_`OPQRSTUV]WXYZ[\ ^abFGHIcL !"#$%&'()*+,-./012     3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgNone !"#/0TH)Determine the terminal width in columns. <This value can be used to format output to fit the terminal.This queries the terminal which is connected to stdout. It may happen, that stdout isn't connected to a terminal, for instance when the program is part of a pipe. In this case, Nothing% is returned. No exception is thrown.See , a, b, ^, c.)Determine the terminal width in columns. <This value can be used to format output to fit the terminal.This queries the terminal which is connected to stdout. It may happen, that stdout isn't connected to a terminal. For instance when the program is part of a pipe. In this case, an IOError is thrown.See , a, b, ^, c.Create and throw an IOError from the current errno5 value, an optional handle and an optional file name.#This is an extended version of the Foreign.C.Error.throwErrnot function from the GHC libraries, which additionally allows to specify a handle and a file name to include in the IOError thrown.See Foreign.C.Error.throwErrno, Foreign.C.Error.errnoToIOError.khAn error which occured when calling an external program. The fields specifiy the details of the call.See x, z, {, System.Posix.ProcessStatus.m Program namenProgram argumentso-The environment in use when the call was donep,The working directory when the call was doneq!The process status of the failurerThe error (errno) codesImproved version of System.Posix.Files.setFileMode", which sets the file name in the IOError] which is thrown in case of an error. The implementation in GHC 6.2.2 neglects to do this. OsetFileMode' path mode = fill_in_filename path $ setFileMode path modetdExecute an IO action as a separate process, and wait for it to finish. Report errors as exceptions.This forks a child process, which performs the specified IO action. In case the child process has been stopped by a signal, the parent blocks.If the action throws an IOError, it is transmitted to the parent. It is then raised there, as if it happened locally. The child then aborts quietly with an exit code of 0.,Exceptions in the child process, other than IOError"s, result in an error message on stderr, and a  ProcessStatus- exception in the parent, with the value of Exited (ExitFailure 1).. The following exceptions are understood by subproc(, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.rIf the child process exits with an exit code other than zero, or it is terminated by a signal, the corresponding  ProcessStatus8 is raised as an exception in the parent program. Only IOError s are transmitted to the parent.!When used in conjunction with an exec] variant, this means that the parent process can tell the difference between failure of the exec_ call itself, and failure of the child program being executed after a successful call of the exec$ variant. In case of failure of the exec call, You get the IOError,, which happened in the child when calling  executeFile\ (from the GHC hierarchical libraries). In case of the called program failing, you get the  ProcessStatus.1Unless you replace the child process, calling an execa variant, the child should let the control flow leave the action normally (unless it throws an IOError4). The child process is then properly terminated by subprocX, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details.>If you want to run an external program, by calling one of the exec7 variants in the child action, you might want to call runprog instead of subproc. Examples:,Run a program with the environment replaced: /subproc (execpe "foobar" ["1","2","3"] new_env)This results in a  ProcessStatus exception: subproc (exec "/bin/false" [])This results in an IOError (unless you actually have /frooble): subproc (exec "/frooble" [])See |, v, ~, , , .udExecute an IO action as a separate process, and wait for it to finish. Report errors as exceptions.KThis function is included only for backwards compatibility. New code should use t instead", which has better error handling.The program forks a child process and performs the specified action. Then it waits for the child process to finish. If it exits in any way which indicates an error, the  ProcessStatus is thrown.WThe parent process waits for the child processes, which have been stopped by a signal.See HsShellScript#subr for further details.See t, v.v[Execute an IO action as a separate process, and continue without waiting for it to finish.{The program forks a child process, which performs the specified action and terminates. The child's process ID is returned.See HsShellScript#subr for further details.See t.wRun an external program. This starts a program as a child process, and waits for it to finish. The executable is searched via the PATH.KThis function is included for backwards compatibility only. New code should use |', which has much better error handling.hWhen the specified program can't be executed, an error message is printed, and the main process gets a  ProcessStatus thrown, with the value Exited (ExitFailure 1). This means that the main program can't distinguish between failure of calling the program and the program exiting with an exit code of 1. However, an error message "Error calling ...", including the description in the IOError produced by the failed execp call, is printed on stderr. run prog par is essentially call (execp prog par).Example: Wrun "/usr/bin/foobar" ["some", "args"] `catch` (\ps -> do -- oops... )See |, t, v.x@Make a readable error message. This includes all the fields of RunError except for the environment.See k.y+Generate a human-readable description of a  ProcessStatus.See ~, | and System.Posix.ProcessStatus0 in the GHC hierarchical library documentation.z Convert a RunError to an IOError.The IOErrorL type isn't capable of holding all the information which is contained in a RunErrorn. The environment is left out, and most of the other fields are included only informally, in the description.The fields of the generated IOError are: The handle ( ioeGetHandle): NothingThe error type (ioeGetErrorType): GHC.IO.Exception.SystemError ioe_location:  "runprog"ioe_description$: The error message, as procuded by  show_runerror. ioe_filename : This is Just (shell_command prog pars), with prog and pars% being the program and its arguments.See {, |, x.{ECall the specified IO action (which is expected to contain calls of runprog) and convert any RunError exceptions to IOErrors.The conversion is done by to_ioe.See z, |.|^Run an external program, and report errors as exceptions. The executable is searched via the PATHM. In case the child process has been stopped by a signal, the parent blocks._In case the program exits in an way which indicates an error, or is terminated by a signal, a RunError6 is thrown. It contains the details of the call. The runprog( action can also be converted to throw IOErrors instaed, by applying as_ioeE to it. Either can be used to generate an informative error message.2In case of starting the program itself failed, an IOError is thrown.runprog prog par is a simple front end to subproc. It is essentially subproc (execp prog par), apart from building a RunError from a  ProcessStatus. Example 1: zdo runprog "foo" ["some", "args"] ... `catch` (\re -> do errm (show_runerror re) ... ) Example 2: do as_ioe $ runprog "foo" ["some", "args"] ... `catch` (\ioe -> do errm (show_ioerror ioe) ... )See t, v, k, x, z, {.}4Print an action as a shell command, then perform it."This is used with actions such as |, ~ or t. For instance, echo runprog prog args is a variant of runprog prog args3, which prints what is being done before doing it.See |, t, ~.~Execute an external program. This replaces the running process. The path isn't searched, the environment isn't changed. In case of failure, an IOError is thrown. 8exec path args = execute_file path False args NothingSee , HsShellScript#exec.Execute an external program. This replaces the running process. The path is searched, the environment isn't changed. In case of failure, an IOError is thrown. 8execp prog args = execute_file prog True args NothingSee , HsShellScript#exec.Execute an external program. This replaces the running process. The path isn't searched, the environment of the program is set as specified. In case of failure, an IOError is thrown. @exece path args env = execute_file path False args (Just env)See , HsShellScript#exec.Execute an external program. This replaces the running process. The path is searched, the environment of the program is set as specified. In case of failure, an IOError is thrown. @execpe prog args env = execute_file prog True args (Just env)See , HsShellScript#exec.!Build left handed pipe of stdout."p -|- q." builds an IO action from the two IO actions p and q. q< is executed in an external process. The standard output of p% is sent to the standard input of q> through a pipe. The result action consists of forking off q (connected with a pipe), and p.The result action does not run pP in a separate process. So, the pipe itself can be seen as a modified action p, forking a connected q/. The pipe is called "left handed", because p remains unforked, and not q.'The exit code of q is silently ignored.) The process ID of the forked copy of q, isn't returned to the caller, so it's lost.The pipe, which connects p and q, is in  text mode$. This means that the output of pl is converted from Unicode to the system character set, which is determined by the environment variable LANG.See HsShellScript#subr and HsShellScript#exec for further details. Examples: ;subproc (exec "/usr/bin/foo" [] -|- exec "/usr/bin/bar" []) sunproc ( execp "foo" ["..."] -|= ( -- Do something with foo's output do cnt <- lazy_contents "-" ... ) ) Ssunproc ( err_to_out foo -|- exec "/usr/bin/tee" ["-a", "/tmp/foo.log"] )See t, '(=|-)', '(-|=)', !Build left handed pipe of stderr."p =|- q." builds an IO action from the two IO actions p and q. qB is executed in an external process. The standard error output of p% is sent to the standard input of q> through a pipe. The result action consists of forking off q (connected with a pipe), and p.The result action does not run pP in a separate process. So, the pipe itself can be seen as a modified action p, forking a connected q/. The pipe is called "left handed", because p has this property, and not q.'The exit code of q is silently ignored.) The process ID of the forked copy of q, isn't returned to the caller, so it's lost.The pipe, which connects p and q, is in  text mode$. This means that the output of pl is converted from Unicode to the system character set, which is determined by the environment variable LANG.See HsShellScript#subr and HsShellScript#exec for further details.Example: ;subproc (exec "/usr/bin/foo" [] =|- exec "/usr/bin/bar" [])See t, '(-|-)', '(-|=)'."Build right handed pipe of stdout."p -|= q." builds an IO action from the two IO actions p and q. p< is executed in an external process. The standard output of p% is sent to the standard input of q> through a pipe. The result action consists of forking off p (connected with a pipe), and q.The result action does not run qP in a separate process. So, the pipe itself can be seen as a modified action q, forking a connected p3. The pipe is called "right handed", because q has this property, and not p.'The exit code of p is silently ignored.) The process ID of the forked copy of q, isn't returned to the caller, so it's lost.The pipe, which connects p and q, is in  text mode$. This means that the output of pl is converted from Unicode to the system character set, which is determined by the environment variable LANG.See HsShellScript#subr and HsShellScript#exec for further details.Example: Esubproc (exec \"\/usr\/bin\/foo\" [] -|= exec \"\/usr\/bin\/bar\" [])See t, '(=|-)', '(=|=)'."Build right handed pipe of stderr."p =|= q." builds an IO action from the two IO actions p and q. pB is executed in an external process. The standard error output of p% is sent to the standard input of q> through a pipe. The result action consists of forking off p (connected with a pipe), and q.The result action does not run qP in a separate process. So, the pipe itself can be seen as a modified action q, forking a connected p3. The pipe is called "right handed", because q has this property, and not p.'The exit code of p is silently ignored.) The process ID of the forked copy of q, isn't returned to the caller, so it's lost.The pipe, which connects p and q, is in  text mode$. This means that the output of pl is converted from Unicode to the system character set, which is determined by the environment variable LANG.See HsShellScript#subr and HsShellScript#exec for further details.Example: ;subproc (exec "/usr/bin/foo" [] =|= exec "/usr/bin/bar" [])See t, , .Temporarily replace a handle. This makes a backup copy of the original handle (typically a standard handle), overwrites it with the specified one, runs the specified action, and restores the handle from the backup.Example: F h <- openFile "/tmp/log" WriteMode redirect stdout h io hClose hThis is the same as  io ->- "/tmp/log"See , .vRedirect the standard output of the specified IO action to a file. The file will be overwritten, if it already exists. What's actually modified is the stdout( handle, not the file descriptor 1. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.The file is written in  text mode. This means that the output is converted from Unicode to the system character set, which is determined by the environment variable LANG.Example: ,runprog "/some/program" [] ->- "/tmp/output"Note: You can't redirect to  "/dev/null" this way, because GHC 6.4's openFileY throws an "invalid argument" IOError. (This may be a bug in the GHC 6.4 libraries). Use ->>- instead.See t, |, , .{Redirect the standard output of the specified IO action to a file. If the file already exists, the output will be appended. What's actually modified is the stdout( handle, not the file descriptor 1. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.The file is written in  text mode. This means that the output is converted from Unicode to the system character set, which is determined by the environment variable LANG.Example: -run "/some/noisy/program" [] ->>- "/dev/null"See t, |, '(->-)', '(=>>-)'.|Redirect the standard error output of the specified IO action to a file. If the file already exists, it will be overwritten. What's actually modified is the stderr( handle, not the file descriptor 2. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.Note: You can't redirect to  "/dev/null" this way, because GHC 6.4's openFileY throws an "invalid argument" IOError. (This may be a bug in the GHC 6.4 libraries). Use =>>- instead.The file is written in  text mode. This means that the output is converted from Unicode to the system character set, which is determined by the environment variable LANG.Example: 'run "/path/to/foo" [] =>- "/tmp/errlog"See t, |, '(->-)', '(=>>-)'.Redirect the standard error output of the specified IO action to a file. If the file already exists, the output will be appended. What's actually modified is the stderr( handle, not the file descriptor 2. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.The file is written in  text mode. This means that the output is converted from Unicode to the system character set, which is determined by the environment variable LANG.Example: 'run "/some/program" [] =>>- "/dev/null"See t, |, '(->>-)', '(=>-)'.MRedirect both stdout and stderr to a file. This is equivalent to the shell's &>> operator. If the file already exists, it will be overwritten.!What's actually modified are the stdout and stderr0 handles, not the file descriptors 1 and 2. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.Note: You can't redirect to  "/dev/null" this way, because GHC 6.4's openFileY throws an "invalid argument" IOError. (This may be a bug in the GHC 6.4 libraries). Use -&>>- instead.The file is written in  text mode. This means that the output is converted from Unicode to the system character set, which is determined by the environment variable LANG. '(-&>-) io path = err_to_out io ->- pathExample: +subproc (exec "/path/to/foo" [] -&>- "log")See '(-&>>-)', .fRedirect both stdout and stderr to a file. If the file already exists, the output will be appended.!What's actually modified are the stdout and stderr0 handles, not the file descriptors 1 and 2. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.The file is written in  text mode. This means that the output is converted from Unicode to the system character set, which is determined by the environment variable LANG. .(-&>>-) io path = (err_to_out >> io) ->>- pathExample: .run "/some/noisy/program" [] -&>>- "/dev/null"See '(-&>-)', .qRedirect stdin from a file. This modifies the specified action, such that the standard input is read from a file. What's actually modified is the stdin+ handle, not the file descriptor 0. The exec# functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details.The file is read in  text mode. This means that the input is converted from the system character set to Unicode. The system's character set is determined by the environment variable LANG.Example: *subproc (exec "/path/to/foo" [] -<- "bar")See ~, |, '(->-)', '(=>-)'.ESend the error output of the specified action to its standard output. What's actually modified is the stdout( handle, not the file descriptor 1. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details. #err_to_out = redirect stderr stdoutSee .ESend the output of the specified action to its standard error output. What's actually modified is the stderr( handle, not the file descriptor 2. The exec functions know about this. See HsShellScript#fdpipes and HsShellScript#exec for details. redirect stdout stderrSee .BRun an IO action as a separate process, and pipe some text to its stdin@. Then close the pipe and wait for the child process to finish.mThis forks a child process, which executes the specified action. The specified text is sent to the action's stdina through a pipe. Then the pipe is closed. In case the action replaces the process by calling an execT variant, it is made sure that the process gets the text on it's file descriptor 0.fIn case the action fails (exits with an exit status other than 0, or is terminated by a signal), the  ProcessStatus! is thrown, such as reported by O. No attempt is made to create more meaningful exceptions, like it is done by runprog/subproc.7Exceptions in the action result in an error message on stderr7, and the termination of the child. The parent gets a  ProcessStatus exception, with the value of Exited (ExitFailure 1)R. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details.The pipe is set to  text mode. This means that the Unicode characters in the text are converted to the system character set. If you need to pipe binary data, you should use  h_pipe_toG, and set the returned handle to binary mode. This is accomplished by  h TrueF. The system character set is determined by the environment variable LANG.Example: ,pipe_to "blah" (exec "/usr/bin/foo" ["bar"])Example: Access both stdin and stdout of an external program. import HsShellScript main = mainwrapper $ do res <- pipe_from $ pipe_to "2\n3\n1" $ exec "/usr/bin/sort" [] putStrLn resSee t, |, , .NRun an IO action as a separate process, and get a connection (a pipe) to its stdin as a file handle.hThis forks a subprocess, which executes the specified action. A file handle, which is connected to its stdin, is returned. The child's  ProcessIDP is returned as well. If the action replaces the child process, by calling an exec_ variant, it is made sure that its file descriptor 0 is connected to the returned file handle.zThis gives you full control of the pipe, and of the forked process. But you must cope with the child process by yourself.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details.LErrors can only be detected by examining the child's process status (using  L). If the child action throws an exception, an error message is printed on stderr&, and the child process exits with a  ProcessStatus of Exited (ExitFailure 1)R. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.OIf the child process exits in a way which signals an error, the corresponding  ProcessStatus is returned by getProcessStatus. See   for details.The pipe is set to  text mode. This means that the Unicode characters in the text are converted to the system character set. You can set the returned handle to binary mode, by calling  handle TrueF. The system character set is determined by the environment variable LANG.Example: (handle, pid) <- h_pipe_to $ exec "/usr/bin/foo" ["bar"] hPutStrLn handle "Some text to go through the pipe" (Just ps) <- getProcessStatus True False pid when (ps /= Exited ExitSuccess) $ throw psSee , , , . See HsShellScript#fdpipes for more details.5Run an IO action as a separate process, and read its stdoute strictly. Then wait for the child process to finish. This is like the backquote feature of shells.This forks a child process, which executes the specified action. The output of the child is read from its standard output. In case it replaces the process by calling an exec[ variant, it is make sure that the output is read from the new process' file descriptor 1.DThe end of the child's output is reached when either the standard output is closed, or the child process exits. The program blocks until the action exits, even if the child closes its standard output earlier. So the parent process always notices a failure of the action (when it exits in a way which indicates an error).RWhen the child action exits in a way which indicates an error, the corresponding  ProcessStatus is thrown. See  O. No attempt is made to create more meaningful exceptions, like it is done by runprog/subproc.7Exceptions in the action result in an error message on stderr>, and the proper termination of the child. The parent gets a  ProcessStatus exception, with the value of Exited (ExitFailure 1)R. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details."Unlike shells' backquote feature,  pipe_fromy does not remove any trailing newline characters. The entire output of the action is returned. You might want to apply chomp to the result.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from stdin, is converted from the system character set to Unicode. The system character set is determined by the environment variable LANGK. If you need to read binary data from the forked process, you should use  h_pipe_fromF and set the returned handle to binary mode. This is accomplished by  h True.Example: *output <- pipe_from $ exec "/bin/mount" []Example: Access both stdin and stdout of an external program. import HsShellScript main = mainwrapper $ do res <- pipe_from $ pipe_to "2\n3\n1" $ exec "/usr/bin/sort" [] putStrLn resSee ~, , , , , chomp, .Run an IO action as a separate process, and read its standard error output strictly. Then wait for the child process to finish. This is like the backquote feature of shells. This function is exactly the same as  pipe_fromQ, except that the standard error output is read, instead of the standard output.This forks a child process, which executes the specified action. The error output of the child is read from its standard error output. In case it replaces the process by calling an exec[ variant, it is made sure that the output is read from the new process' file descriptor 2.]The end of the child's error output is reached when either the standard error output is closed, or the child process exits. The program blocks until the action exits, even if the child closes its standard error output earlier. So the parent process always notices a failure of the action (which means it exits in a way which indicates an error).RWhen the child action exits in a way which indicates an error, the corresponding  ProcessStatus is thrown. See  P. No attempt is made to create more meaningful exceptions, like it is done by runprog/subproc.7Exceptions in the action result in an error message on stderr, and the proper termination of the child. This means that the error message is sent through the pipe, to the parent process. The message can be found in the text which has been read from the child process. It doesn't appear on the console.The parent gets a  ProcessStatus exception, with the value of Exited (ExitFailure 1)R. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details."Unlike shells' backquote feature,  pipe_from2 does not remove any trailing newline characters. The entire error output of the action is returned. You might want to apply chomp to the result.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from stdin, is converted from the system character set to Unicode. The system character set is determined by the environment variable LANGK. If you need to read binary data from the forked process, you should use  h_pipe_fromF and set the returned handle to binary mode. This is accomplished by  h True.Example: *output <- pipe_from $ exec "/bin/mount" []Example: Access both stdin and stdout of an external program. import HsShellScript main = mainwrapper $ do res <- pipe_from $ pipe_to "2\n3\n1" $ exec "/usr/bin/sort" [] putStrLn resSee ~, , , , , . See HsShellScript#fdpipes for more details.;Run an IO action as a separate process, and connect to its stdoutD with a file handle. This is like the backquote feature of shells.hThis forks a subprocess, which executes the specified action. A file handle, which is connected to its stdout, is returned. The child's  ProcessIDP is returned as well. If the action replaces the child process, by calling an exec_ variant, it is made sure that its file descriptor 1 is connected to the returned file handle.zThis gives you full control of the pipe, and of the forked process. But you must cope with the child process by yourself.When you call getProcessStatus blockingly, you must first ensure that all data has been read, or close the handle. Otherwise you'll get a deadlock. When you close the handle before all data has been read, then the child gets a SIGPIPE signal.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details.LErrors can only be detected by examining the child's process status (using  P). No attempt is made to create more meaningful exceptions, like it is done by runprog/subprocK. If the child action throws an exception, an error message is printed on stderr&, and the child process exits with a  ProcessStatus of Exited (ExitFailure 1)S. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from stdin, is converted from the system character set to Unicode. The system character set is determined by the environment variable LANG. If you need to read binary data from the forked process, you can set the returned handle to binary mode. This is accomplished by  h True.Example: 4(h,pid) <- h_pipe_from $ exec "/usr/bin/foo" ["bar"]See ~, , , , , chomp, . See HsShellScript#fdpipes for more details.;Run an IO action as a separate process, and connect to its stderr with a file handle.hThis forks a subprocess, which executes the specified action. A file handle, which is connected to its stderr, is returned. The child's  ProcessIDP is returned as well. If the action replaces the child process, by calling an exec_ variant, it is made sure that its file descriptor 2 is connected to the returned file handle.zThis gives you full control of the pipe, and of the forked process. But you must cope with the child process by yourself.When you call getProcessStatus blockingly, you must first ensure that all data has been read, or close the handle. Otherwise you'll get a deadlock. When you close the handle before all data has been read, then the child gets a SIGPIPE signal.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details.LErrors can only be detected by examining the child's process status (using  P). No attempt is made to create more meaningful exceptions, like it is done by runprog/subprocK. If the child action throws an exception, an error message is printed on stderrq. This means that the message goes through the pipe to the parent process. Then the child process exits with a  ProcessStatus of Exited (ExitFailure 1)S. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from stdin, is converted from the system character set to Unicode. The system character set is determined by the environment variable LANG. If you need to read binary data from the forked process, you can set the returned handle to binary mode. This is accomplished by  h True.Example: 4(h,pid) <- h_pipe_from $ exec "/usr/bin/foo" ["bar"]See ~, , , , , , chomp, .Run an IO action in a separate process, and read its standard output, The output is read lazily, as the returned string is evaluated. The child's output along with its process ID are returned.This forks a child process, which executes the specified action. The output of the child is read lazily through a pipe, which connncts to its standard output. In case the child replaces the process by calling an exec\ variant, it is make sure that the output is read from the new process' file descriptor 1.lazy_pipe_from calls %, in order to read the pipe lazily. This means that the file handle goes to semi-closed state. The handle holds a file descriptor, and as long as the string isn't fully evaluated, this file descriptor won't be closed. For the file descriptor to be closed, first its standard output needs to be closed on the child side. This happens when the child explicitly closes it, or the child process exits. When afterwards the string on the parent side is completely evaluated, the handle, along with the file descritor it holds, are closed and freed.If you use the string in such a way that you only access the beginning of the string, the handle will remain in semi-closed state, holding a file descriptor, even when the pipe is closed on the child side. When you do that repeatedly, you may run out of file descriptors.Unless you're sure that your program will reach the string's end, you should take care for it explicitly, by doing something like this: b(output, pid) <- lazy_pipe_from (exec "\/usr\/bin\/foobar" []) ... seq (length output) (return ())This will read the entire standard output of the child, even if it isn't needed. You can't cut the child process' output short, when you use lazy_pipe_from). If you need to do this, you should use  h_pipe_from;, which gives you the handle, which can then be closed by ., even if the child's output isn't completed: (h, pid) <- h_pipe_from io -- Lazily read io's output output <- hGetContents h ... -- Not eveyting read yet, but cut io short. hClose h -- Wait for io to finish, and detect errors (Just ps) <- System.Posix.getProcessStatus True False pid when (ps /= Exited ExitSuccess) $ throw psPWhen you close the handle before all data has been read, then the child gets a SIGPIPE signal.4After all the output has been read, you should call getProcessStatusz on the child's process ID, in order to detect errors. Be aware that you must evaluate the whole string, before calling getProcessStatus' blockingly, or you'll get a deadlock.You won't get an exception, if the child action exits in a way which indicates an error. Errors occur asynchronously, when the output string is evaluated. You must detect errors by yourself, by calling  .In case the action doesn't replace the child process with an external program, an exception may be thrown out of the action. This results in an error message on stderr0, and the proper termination of the child. The  ProcessStatus2, which can be accessed in the parent process by getProcessStatus, is Exited (ExitFailure 1)R. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details."Unlike shells' backquote feature, lazy_pipe_fromy does not remove any trailing newline characters. The entire output of the action is returned. You might want to apply chomp to the result.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from the IO action's stdout, are converted from the system character set to Unicode. The system character set is determined by the environment variable LANG. If you need to read binary data from the forked process, you should use h_pipe_from and set the returned handle to binary mode. This is accomplished by  h TrueF. Then you can lazily read the output of the action from the handle.mExample: Lazily read binary data from an IO action. Don't forget to collect the child process later, using  True False pid. (h, pid) <- h_pipe_from io hSetBinaryMode h True txt <- hGetContents h ... (Just ps) <- System.Posix.getProcessStatus True False pidSee ~, , , , , .Run an IO action in a separate process, and read its standard error output, The output is read lazily, as the returned string is evaluated. The child's error output along with its process ID are returned.This forks a child process, which executes the specified action. The error output of the child is read lazily through a pipe, which connncts to its standard error output. In case the child replaces the process by calling an exec\ variant, it is make sure that the output is read from the new process' file descriptor 1.lazy_pipe_from calls +, in order to read the pipe lazily. This means that the file handle goes to semi-closed state. The handle holds a file descriptor, and as long as the string isn't fully evaluated, this file descriptor won't be closed. For the file descriptor to be closed, first its standard error output needs to be closed on the child side. This happens when the child explicitly closes it, or the child process exits. When afterwards the string on the parent side is completely evaluated, the handle, along with the file descritor it holds, are closed and freed.If you use the string in such a way that you only access the beginning of the string, the handle will remain in semi-closed state, holding a file descriptor, even when the pipe is closed on the child side. When you do that repeatedly, you may run out of file descriptors.Unless you're sure that your program will reach the string's end, you should take care for it explicitly, by doing something like this: `(errmsg, pid) <- lazy_pipe_from2 (exec "/usr/bin/foobar" []) ... seq (length errmsg) (return ())This will read the entire standard error output of the child, even if it isn't needed. You can't cut the child process' output short, when you use lazy_pipe_from). If you need to do this, you should use  h_pipe_from;, which gives you the handle, which can then be closed by ., even if the child's output isn't completed: (h, pid) <- h_pipe_from io -- Lazily read io's output output <- hGetContents h ... -- Not eveyting read yet, but cut io short. hClose h -- Wait for io to finish, and detect errors (Just ps) <- System.Posix.getProcessStatus True False pid when (ps /= Exited ExitSuccess) $ throw psPWhen you close the handle before all data has been read, then the child gets a SIGPIPE signal.4After all the output has been read, you should call getProcessStatusz on the child's process ID, in order to detect errors. Be aware that you must evaluate the whole string, before calling getProcessStatus' blockingly, or you'll get a deadlock.You won't get an exception, if the child action exits in a way which indicates an error. Errors occur asynchronously, when the output string is evaluated. You must detect errors by yourself, by calling  .In case the action doesn't replace the child process with an external program, an exception may be thrown out of the action. This results in an error message on stderr. This means that the message is sent through the pipe, to the parent process. Then the child process is properly terminated. The  ProcessStatus2, which can be accessed in the parent process by getProcessStatus, is Exited (ExitFailure 1)R. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.1Unless you replace the child process, calling an exec variant, the child should let the control flow leave the action normally. The child process is then properly terminated, such that no resources, which have been duplicated by the fork, cause problems. See HsShellScript#subr for details.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from stdin, is converted from the system character set to Unicode. The system character set is determined by the environment variable LANG. If you need to read binary data from the forked process, you can set the returned handle to binary mode. This is accomplished by  h True."Unlike shells' backquote feature, lazy_pipe_fromy does not remove any trailing newline characters. The entire output of the action is returned. You might want to apply chomp to the result.The pipe is set to  text mode. This means that the Unicode characters in the text, which is read from the IO action's stdout, are converted from the system character set to Unicode. The system character set is determined by the environment variable LANG. If you need to read binary data from the forked process' standard error output, you should use h_pipe_from2 and set the returned handle to binary mode. This is accomplished by  h TrueD. Then you can lazily read the output of the action from the handle.mExample: Lazily read binary data from an IO action. Don't forget to collect the child process later, using  True False pid. (h, pid) <- h_pipe_from2 io hSetBinaryMode h True txt <- hGetContents h ... (Just ps) <- System.Posix.getProcessStatus True False pidSee ~, , , , , .GRun an IO action as a separate process, and optionally connect to its stdin, its stdout and its stderr output with pipes.KThis forks a subprocess, which executes the specified action. The child's  ProcessID is returned. Some of the action's standard handles are made to connected to pipes, which the caller can use in order to communicate with the new child process. Which, this is determined by the first three arguments.tYou get full control of the pipes, and of the forked process. But you must cope with the child process by yourself.YErrors in the child process can only be detected by examining its process status (using  L). If the child action throws an exception, an error message is printed on stderr&, and the child process exits with a  ProcessStatus of Exited (ExitFailure 1)S. The following exceptions are understood, and result in corresponding messages: ArgError,  ProcessStatus, RunError, IOError and ExitCodeB. Other exceptions result in the generic message, as produced by show.1Unless you replace the child process, calling an execo variant, the child should let the control flow leave the action normally. It is then properly take care of.The pipes are set to  text mode!. When connecting to the child's stdin, this means that the Unicode characters in the Haskell side text are converted to the system character set. When reading from the child's stdout or stderr, the text is converted from the system character set to Unicode in the Haskell-side strings. The system character set is determined by the environment variable LANGP. If you need to read or write binary data, then this is no problem. Just call  handle True3. This sets the corresponding pipe to binary mode.See , , , , , , , FForcibly terminate the program, circumventing normal program shutdown. This is the _exit(2)0 system call. No cleanup actions installed with bracketE are performed, no data buffered by file handles is written out, etc."Generate an error message from an errno value. This is the POSIX strerror system library function.See the man page  strerror(3).7Read the global system error number. This is the POSIX errno) value. This function is redundant. Use Foreign.C.Error.getErrno instead.3Print error message corresponding to the specified errnoE error number. This is similar to the POSIX system library function perror.See the man page  perror(3).0Print error message corresponding to the global errnoF error number. This is the same as the POSIX system library function perror.See the man page  perror(3).Print a message to stderr1 and exit with an exit code indicating an error. 0failIO msg = hPutStrLn stderr msg >> exitFailurehModify an IO action to return the exit code of a failed program call, instead of throwing an exception.QThis is used to modify the error reporting behaviour of an IO action which uses 'run'/'runprog' or 'call'/'subproc'v. When an external program exits with an exit code which indicates an error, normally an exception is thrown. After exitcode5 has been applied, the exit code is retruned instead.The caught exceptions are k and V. Termination by a signal is still reported by an exception, which is passed through. Example: &ec <- exitcode $ runprog "foo" ["bar"]See |, t, w, u. Convert an IOError to a string.$There is an instance declaration of IOError in Show in the GHC.IO library, but  show_ioerror7 produces a more readable, and more complete, message.DCall the shell to execute a command. In case of an error, throw the  ProcessStatus (such as (Exited (ExitFailure ec))I) as an exception. This is like the Haskell standard library function systemR, except that error handling is brought in accordance with HsShellScript's scheme.exitcode . system_throw is the same as the systemm function, except that when the called shell is terminated or stopped by a signal, this still lead to the  ProcessStatusj being thrown. The Haskell library report says nothing about what happens in this case, when using the system function. 2system_throw cmd = run "/bin/sh" ["-c", "--", cmd]3This function is deprecated. You should rather use 1, which provides for much better error reporting.<Call the shell to execute a command. In case of an error, a RunErrorC ist thrown. This is like the Haskell standard library function system], except that error handling is brought in accordance with HsShellScript's scheme. (It is not a front end to system.) 8system_runprog cmd = runprog "/bin/sh" ["-c", "--", cmd])Example: Call "foo" and report Errors as IOErrors, rather than RunErrors. ,as_ioe $ system_runprog "foo" ["bar", "baz"]See k, {URun a subroutine as a child process, but don't let it produce any messages. Read its stdout and stderr instead, and append it to the contents of a mutable variable. The idea is that you can run some commands silently, and report them and their messages to the user only when something goes wrong.yIf the child process terminates in a way which indicates an error, then the process status is thrown, in the same way as |# does. If the subroutine throws an  (Exited ec) exception (of type  ProcessStatus), such as thrown by |z, then the child process exits with the same exit code, such that the parent process reports it to the caller, again as a  ProcessStatus exception.CWhen the subroutine finishes, the child process is terminated with  0U. When it throws an exception, an error message is printed and it is terminated with  1. See HsShellScript#subr for details.The standard output (and the standard error output) of the parent process are flushed before the fork, such that no output appears twice.Example:  let handler :: IORef String -> ProcessStatus -> IO () handler msgref ps = do hPutStrLn stderr ("Command failed with " ++ show ps ++ ". Actions so far: ") msg <- readIORef msgref hPutStrLn stderr msg exitWith (ExitFailure 1) msgref <- newIORef "" do silently msgref $ do putStrLn "Now doing foobar:" echo exec "/foo/bar" ["arguments"] silently msgref $ echo exec "/bar/baz" ["arguments"] `catch` (handler msgref)See , t, | , Data.IORef.UModify a subroutine action in order to make it suitable to run as a child process.This is used by functions like u, , Y etc. The action is executed. When it returns, the (child) process is terminated with  0 (after flushing stdout), circumventing normal program shutdown. When it throws an exception, an error message is printed and the (child) process is terminated with  1.Print text to stdout.This is a shorthand for putStrLn , except for stderr being flushed beforehand. This way normal output and error output appear in order, even when they aren't buffered as by default.,An additional newline is printed at the end. .outm msg = do hFlush stderr putStrLn msgPrint text to stdout.This is a shorthand for putStr , except for stderr being flushed beforehand. This way normal output and error output appear in order, even when they aren't buffered as by default.!No newline is printed at the end. -outm_ msg = do hFlush stderr putStr msgColorful log message to stderr.This prints a message to stderr. When stderr1 is connected to a terminal (as determined by  isatty(3)), additional escape sequences are printed, which make the message appear in cyan. Additionally, a newline character is output at the end.stdout{ is flushed beforehand. So normal output and error output appear in order, even when they aren't buffered as by default.See , , .Colorful log message to stderr.This prints a message to stderr. When stderr1 is connected to a terminal (as determined by  isatty(3)), additional escape sequences are printed, which make the message appear in cyan. No a newline character is output at the end.stdout{ is flushed beforehand. So normal output and error output appear in order, even when they aren't buffered as by default.See , , .Colorful error message to stderr.This prints a message to stderr. When stderr1 is connected to a terminal (as determined by  isatty(3)), additional escape sequences are printed, which make the message appear in red. Additionally, a newline character is output at the end.stdout{ is flushed beforehand. So normal output and error output appear in order, even when they aren't buffered as by default.See , , .Colorful error message to stderr.This prints a message to stderr. When stderr1 is connected to a terminal (as determined by  isatty(3)), additional escape sequences are printed, which make the message appear in red. No a newline character is output at the end.stdout{ is flushed beforehand. So normal output and error output appear in order, even when they aren't buffered as by default.See , , .In case the specified action throws an IOError, fill in its filename field. This way, more useful error messages can be produced.Example: -- Oh, the GHC libraries neglect to fill in the file name executeFile' prog a b c = fill_in_filename prog $ executeFile prog a b cSee , .In case the specified action throws an IOError, fill in its location field. This way, more useful error messages can be produced.Example: my_fun a b c = do -- ... fill_in_location "my_fun" $ -- Give the caller a more useful location information in case of failure rename "foo" "bar" -- ...See .KIn case the specified action throws an IOError, add a line to its location field. This way, more useful error messages can be produced. The specified string is prepended to the old location, separating it with a newline from the previous location, if any. When using this thoroughly, you get a reverse call stack in IOErrors.Example: 3my_fun = add_location "my_fun" $ do -- ...See , .This is a replacement for  System.Posix.Process.executeFile1. It does additional preparations, then calls  executeFile.  executeFile can't normally <be used directly, because it doesn't do the things which are outlined here.This are the differences to  executeFile: stdout and stderr are flushed.The standard file descriptors 0-2 are made copies of the file descriptors which the standard handles currently use. This is necessary because they might no longer use the standard handles. See HsShellScript#fdpipes.If the standard handles stdin, stdout, stderr aren't in closed state, and they aren't already connected to the respective standard file descriptors, their file descriptors are copied to the respective standard file descriptors (with dup2). Backup copies are made of the file descriptors which are overwritten. If some of the standard handles are closed, the corresponding standard file descriptors are closed as well. UAll file descriptors, except for the standard ones, are set to close-on-exec (see fcntl(2)x), and will be closed on successful replacement of the process. Before that, the old file descriptor flags are saved.The standard file descriptors are set to blocking mode, since GHC 6.2.2 sets file descriptors to non-blocking (except 0-2, which may get overwritten by a non-blocking one in step 2). The called program doesn't expect that.In case replacing the process fails, the file descriptors are reset to the original state. The file descriptors flags are restored, and the file descriptors 0-2 are overwritten again, with their backup copies. Then an IOError is thrown.;In any IOError, the program is filled in as the file name ( executeFile neglects this).The return type is a generic a, rather than (). Also see HsShellScript#exec.-Check if a handle is connected to a terminal.This is a front end to the  isatty(3)w function (see man page). It is useful, for instance, to determine if color escape sequences should be generated. The GHC libraries don't declare Foreign.C.Error.Errno( as instance of Show. This makes it up.d.Handle, which is connected to the terminal oThe number of columns in the constrolling terminal. Nothing, when the handle isn't connected to a terminal..Handle, which is connected to the terminal xThe number of columns in the constrolling terminal. Throws an IOError when the handle isn't connected to a terminal.ADescription of the location where the error occurs in the programOptional handle4Optional file name (for failing operations on files)klmnopqr !"#$%&'()st$Action to execute in a child processu$action to execute as a child processv%Action to execute as a child process.Process ID of the new process.*wName of the executable to runCommand line argumentsxyz{|Name of the executable to runCommand line arguments}Action to perform%Name or path of the executable to runCommand line arguments~Full path to the executableCommand line arguments Never returnsName or path of the executableCommand line arguments Never returnsFull path to the executableCommand line argumentsNew environment Never returnsName or path of the executableCommand line argumentsNew environment Never returnsAction which won't be forked5Action which will be forked and connected with a pipe Result actionAction which won't be forked5Action which will be forked and connected with a pipe Result action5Action which will be forked and connected with a pipeAction which won't be forked Result action5Action which will be forked and connected with a pipeAction which won't be forked Result actionHandle to replaceHandle to replace it withAction+'Action, whose output will be redirectedFile to redirect the output to Result action'Action, whose output will be redirectedFile to redirect the output to Result action-Action, whose error output will be redirected$File to redirect the error output to Result action-Action, whose error output will be redirected$File to redirect the error output to Result action8Action, whose output and error output will be redirectedFile to redirect to Result action8Action, whose output and error output will be redirectedFile to redirect to Result action, Text to pipe3Action to run as a separate process, and to pipe to3Action to run as a separate process, and to pipe to_Returns handle connected to the standard input of the child process, and the child's process IDBAction to run as a separate process. Its return value is ignored.The action's standard output#Action to run as a separate process"The action's standard error output5Action to run as a separate process, and to pipe from`Returns handle connected to the standard output of the child process, and the child's process ID5Action to run as a separate process, and to pipe from`Returns handle connected to the standard output of the child process, and the child's process ID#Action to run as a separate process@The action's lazy output and the process ID of the child process#Action to run as a separate process@The action's lazy output and the process ID of the child processAction to run in a new processWhether to make stdin pipeWhether to make stdout pipeWhether to make stderr pipePipes to the new process's stdin, stdout and stderr$, if applicable; and its process id. Exit code Never returnserrno valueCorresponding error messageerrno valueerrno error number+Text to precede the message, separated by ": "+Text to precede the message, separated by ": "Action to modifyModified actionUA mutable variable, which gets the output (stdout and stderr) of the action appended.The IO action to run.Message to printMessage to printMessage to printFile name to fill inIO action to modifyModified IO actionLocation name to fill inIO action to modifyModified IO actionLocation name to addIO action to modifyModified IO actionProgram to callSearch PATH? ArgumentsOptionally new environment Never returns-./Handle to check-Whether the handle is connected to a terminal0123456789aklmnopqr !"#$%&'()stuv*wxyz{|}~+,-./01234567]klmnopqr !"#$%&'()stuv*wxyz{|}~+,-./0123456789 22223333333 None !"#/0T4One entry of mount information. This is the same as  struct mntent from  <mntent.h>L. A list of these is returned by the functions which read mount information.See , , .+Device file ("name of mounted file system") Mount point*Which kind of file system ("see mntent.h")Mount options ("see mntent.h")Dump frequency in days"Pass number on parallel fsck" Format an Int9 with leading zeros. If the string representation of the Ingb is longer than the number of characters to fill up, this produces as many characters as needed.4Remove trailing newlines. This is silimar to perl's chomp procedure.Get contents of a file or of stdin. This is a simple frontend to  hGetContents. A file name of "-"K designates stdin. The contents are read lazily as the string is evaluated.(The handle which we read from will be in semi-closed state. Once all input has read, it is closed automatically (Haskell Library Report 11.2.1). Therefore we don't need to return it). rlazy_contents path = do h <- if path == "-" then return stdin else openFile path ReadMode hGetContents hGet contents of a file or of stdin eagerly. This is the same as  lazy_contents2, except for the contents being read immediately.>Test for the existence of a path. This is the disjunction of Directory.doesDirectoryExist and Directory.doesFileExist,. For an dangling symlink, this will return False.,Test for the existence of a path. This uses  System.Posix.Files.getFileStatusm to determine whether the path exists in any form in the file system. For a dangling symlink, the result is True.5Test if path points to a directory. This will return True= for a symlink pointing to a directory. It's a shortcut for Directory.doesDirectoryExist.7Test if path points to a file. This is a shortcut for Directory.doesFileExist. This is the  System.Posix.Files.getFileStatusx function from the GHC libraries, with improved error reporting. The GHC function doesn't include the file name in the IOError> when the call fails, making error messages much less useful. getFileStatus' rectifies this.See  . This is the System.Posix.Files.fileAccessx function from the GHC libraries, with improved error reporting. The GHC function doesn't include the file name in the IOError> when the call fails, making error messages much less useful.  fileAccess' rectifies this.See  .XCreate a temporary file. This will create a new, empty file, with a path which did not previously exist in the file system. The path consists of the specified prefix, a sequence of random characters (digits and letters), and the specified suffix. The file is created with read-write permissions for the user, and no permissons for the group and others. The ownership is set to the effective user ID of the process. The group ownership is set either to the effective group ID of the process or to the group ID of the parent directory (depending on filesystem type and mount options on Linux - see open(2) for details).See , , .Create a temporary directory. This will create a new directory, with a path which did not previously exist in the file system. The path consists of the specified prefix, a sequence of random characters (digits and letters), and the specified suffix. The directory is normally created with read-write-execute permissions for the user, and no permissons for the group and others. But this may be further restricted by the process's umask in the usual way.ZThe newly created directory will be owned by the effective uid of the process. If the directory containing the it has the set group id bit set, or if the filesystem is mounted with BSD group semantics, the new directory will inherit the group ownership from its parent; otherwise it will be owned by the effective gid of the process. (See mkdir(2))See , , .Create a temporary file. This will create a new, empty file, with read-write permissions for the user, and no permissons for the group and others. The path consists of the specified prefix, a dot, and six random characters (digits and letters). 0tmp_file prefix = temp_file 6 (prefix ++ ".") ""See , , .4Create a temporary directory. This will create a new directory, with read-write-execute permissions for the user (unless further restricted by the process's umask), and no permissons for the group and others. The path consists of the specified prefix, a dot, and six random characters (digits and letters). .tmp_dir prefix = temp_dir 6 (prefix ++ ".") ""See , , .tCreate and open a temporary file, perform some action with it, and delete it afterwards. This is a front end to the  function. The file and its path are created in the same way. The IO action is passed a handle of the new file. When it finishes - normally or with an exception - the file is deleted.See , , .pCreate a temporary directory, perform some action with it, and delete it afterwards. This is a front end to the  function. The directory and its path are created in the same way. The IO action is passed the path of the new directory. When it finishes - normally or with an exception - the directory is deleted.NThe action must clean up any files it creates inside the directory by itself.  with_temp_dirg doesn't delete any files inside, so the directory could be removed. If the directory isn't empty, an IOErrorA results (with the path filled in). When the action throws an exception, and the temporary directory cannot be removed, then the exception is passed through, rather than replacing it with the IOError. (This is because it's probably exactly because of that exception that the directory isn't empty and can't be removed).See , , .tCreate and open a temporary file, perform some action with it, and delete it afterwards. This is a front end to the  function. The file and its path are created in the same way. The IO action is passed a handle of the new file. When it finishes - normally or with an exception - the file is deleted.See , , .pCreate a temporary directory, perform some action with it, and delete it afterwards. This is a front end to the  function. The directory and its path are created in the same way. The IO action is passed the path of the new directory. When it finishes - normally or with an exception - the directory is deleted.NThe action must clean up any files it creates inside the directory by itself.  with_temp_dirg doesn't delete any files inside, so the directory could be removed. If the directory isn't empty, an IOErrorA results (with the path filled in). When the action throws an exception, and the temporary directory cannot be removed, then the exception is passed through, rather than replacing it with the IOError. (This is because it's probably exactly because of that exception that the directory isn't empty and can't be removed). >with_tmp_dir prefix io = with_temp_dir 6 (prefix ++ ".") "" ioSee , , .Create a temporary path. This will generate a path which does not yet exist in the file system. It consists of the specified prefix, a sequence of random characters (digits and letters), and the specified suffix.DAvoid relying on the generated path not to exist in the file system.f Or else you'll get a potential race condition, since some other process might create the path after  temp_pathR, before you use it. This is a security risk. The global random number generator (Random.randomRIO) is used to generate the random characters. These might not be that random after all, and could potentially be guessed. Rather use  temp_file or temp_dir.See , .3Read mount information. This is a front end to the  setmntent(3),  getmntent(3),  endmntent(3) system library functions. When the  setmntent call fails, the errno value is converted to an IOError and thrown.See , .'Get the currently mounted file systems. #read_mtab = read_mounts "/etc/mtab"See .&Get the system wide file system table. %read_fstab = read_mounts "/etc/fstab"See ."This is an interface to the POSIX glob function, which does wildcard expansion in paths. The sorted list of matched paths is returned. It's empty for no match (rather than the original pattern). In case anything goes wrong (such as permission denied), an IOError is thrown. This does notJ do tilde expansion, which is done (among many unwanted other things) by wordexp%. The only flag used for the call to glob is GLOB_ERR.lThe behaviour in case of non-existing path components is inconsistent in the GNU version of the underlying glob function. glob "/doesnt_exist/foo"& will return the empty list, whereas glob "/doesnt_exist/*"/ causes a "No such file or directory" IOError.See man pages glob(3) and  wordexp(3).*Quote special characters for use with the glob function.The characters *, ?, [ and \] must be quoted by preceding backslashs, when they souldn't have their special meaning. The  glob_quote function does this.You can't use quote or  shell_quote.See , quote,  shell_quote+:;<=>?@ABCHow many characters to fill upValue to represent as a stringLString representation of the value, using the specified number of charactersString to be chomped8Same string, except for no newline characters at the endEither the name of a file, or "-"(The lazily read contents of the file or stdin.either the name of a file, or "-" for stdin-the contents of the file or of standard inputPath*Whether the path exists in the file systemPath*Whether the path exists in the file systemPath2Whether the path exists and points to a directory.Path-Whether the path exists and points to a file./Path of the file, whose status is to be queriedStatus of the filesNumber of random characters to intersperse. Must be large enough, such that most combinations can't already exist. Prefix for the path to generate. Suffix for the path to generate.Path of the created file.sNumber of random characters to intersperse. Must be large enough, such that most combinations can't already exist. Prefix for the path to generate. Suffix for the path to generate.Generated path. Prefix for the path to generate.Path of the created file. Prefix for the path to generate.Path of the created directory.sNumber of random characters to intersperse. Must be large enough, such that most combinations can't already exist. Prefix for the path to generate. Suffix for the path to generate.Action to perform.)Returns the value returned by the action.uNumber of random characters to intersperse. Must be large enough, such that most combinations can't already exist. Prefix for the path to generate. Suffix for the path to generate.Action to perform.)Returns the value returned by the action. Prefix for the path to generate.Action to perform.)Returns the value returned by the action. Prefix for the path to generate.Action to perform.)Returns the value returned by the action.sNumber of random characters to intersperse. Must be large enough, such that most combinations can't already exist. Prefix for the path to generate. Suffix for the path to generate.Generated path.DFile to read (typically  /etc/mtab or  /etc/fstab)Mount information in that filePatternSorted list of matching paths+:;<=>?@ABCD$:;<=>?@ABCDNone !"#/0TDo a call to the  realpath(3) system library function. This makes the path absolute, normalizes it and expands all symbolic links. In case of an error, an IOError is thrown.7Determine the target of a symbolic link. This uses the  readlink(2) system call. The result is a path which is either absolute, or relative to the directory which the symlink is in. In case of an error, an IOError; is thrown. The path is included and can be accessed with IO.ioeGetFileNameg. Note that, if the path to the symlink ends with a slash, this path denotes the directory pointed to, notP the symlink. In this case the call to will fail because of "Invalid argument".7Determine the target of a symbolic link. This uses the  readlink(2) system call. The target is converted, such that it is relative to the current working directory, if it isn't absolute. Note that, if the path to the symlink ends with a slash, this path denotes the directory pointed to, not' the symlink. In this case the call to readlink will fail with an IOError@ because of "Invalid argument". In case of any error, a proper IOError is thrown.RDetermine whether a path is a symbolic link. The result for a dangling symlink is TrueI. The path must exist in the file system. In case of an error, a proper IOError is thrown.Return the normalised, absolute version of a specified path. The path is made absolute with the current working directory, and is syntactically normalised afterwards. This is the same as what the realpath program reports with the -s option. It's almost the same as what it reports when called from a shell. The difference lies in the shell's idea of the current working directory. See  for details.See ,  ."Make a symbolic link. This is the  symlink(2)# function. Any error results in an IOError> thrown. The path of the intended symlink is included in the IOError and can be accessed with ioeGetFileName# from the Haskell standard library IO. Call the du program. See du(1).)Create directory. This is a shorthand to  System.Directory.createDirectoryV from the Haskell standard library. In case of an error, the path is included in the IOError,, which GHC's implementation neglects to do.Remove directory. This is Directory.removeDirectoryV from the Haskell standard library. In case of an error, the path is included in the IOError,, which GHC's implementation neglects to do.Remove file. This is Directory.removeFileF from the Haskell standard library, which is a direct frontend to the  unlink(2) system call in GHC.'Change directory. This is an alias for Directory.setCurrentDirectoryX from the Haskell standard library. In case of an error, the path is included in the IOError,, which GHC's implementation neglects to do.<Note that this command is subtly different from the shell's cd command. It changes the process' working directory. This is always a realpath. Symlinks are expanded. The shell, on the other hand, keeps track of the current working directory separately, in a different way: symlinks are notq expanded. The shell's idea of the working directory is different from the working directory which a process has.%This means that the same sequence of cd commands, when done in a real shell script, will lead into the same directory. But the working directory as reported by the shell's pwd< command may differ from the corresponding one, reported by getCurrentDirectory.Z(When talking about the "shell", I'm talking about bash, regardless of whether started as  /bin/bash or in compatibility mode, as /bin/shH. I presume it's the standard behavior for the POSIX standard shell.)See , 1Get program start working directory. This is the PWD environent variable, which is kept by the shell (bash, at least). It records the directory path in which the program has been started. Symbolic links in this path aren't expanded. In this way, it differs from getCurrentDirectory# from the Haskell standard library.See , Change the working directory temporarily. This executes the specified IO action with a new working directory, and restores it afterwards (exception-safely).Execute  /bin/chmod chmod = run "/bin/chmod"Execute  /bin/chown chown = run "/bin/chown"Execute the cp programExecute the mv program. This calls the /bin/mv to rename a file, or move it to another directory. You can move a file to another file system with this. This starts a new process, which is rather slow. Consider using rename instead, when possible.See .Run the command  mt status; for querying the tape drive status, and parse its output.The  rename(2)/ system call to rename and/or move a file. The  renameFile action from the Haskell standard library doesn't do it, because the two paths may not refer to directories. Failure results in an IOError thrown. The new path is included in the IOError and can be accessed with IO.ioeGetFileName. Rename a file. This first tries }, which is most efficient. If it fails, because source and target path point to different file systems (as indicated by the errno value EXDEV), then /bin/mv is called.See , .;Rename a file or directory, and cope with read only issues.(This renames a file or directory, using renamem, sets the necessary write permissions beforehand, and restores them afterwards. This is more efficient than force_mvp, because no external program needs to be called, but it can rename files only inside the same file system. See  force_cmd for a detailed description.The new path may be an existing directory. In this case, it is assumed that the old file is to be moved into this directory (like with mvx). The new path is then completed with the file name component of the old path. You won't get an "already exists" error. force_rename = force_cmd renameSee , .9Move a file or directory, and cope with read only issues.;This moves a file or directory, using the external command mvm, sets the necessary write permissions beforehand, and restores them afterwards. This is less efficient than  force_rename, because the external program mvE needs to be called, but it can move files between file systems. See  force_cmd for a detailed description. oforce_mv src tgt = fill_in_location "force_mv" $ force_cmd (\src tgt -> run "/bin/mv" ["--", src, tgt]) src tgtSee , .Rename a file with , or when necessary with !, and cope with read only issues.eThe necessary write permissions are set, then the file is renamed, then the permissions are restored. First, the  system call is tried, which is most efficient. If it fails, because source and target path point to different file systems (as indicated by the errno value EXDEV), then /bin/mv is called. Zforce_rename_mv old new = fill_in_location "force_rename_mv" $ force_cmd rename_mv old newSee , , , .OCall a command which moves a file or directory, and cope with read only issues.This function is for calling a command, which renames files. Beforehand, write permissions are set in order to enable the operation, and afterwards the permissions are restored. The command is meant to be something like rename or  run "/bin/mv".VIn order to change the name of a file or dirctory, but leave it in the super directory it is in, the super directory must be writeable. In order to move a file or directory to a different super directory, both super directories and the file/directory to be moved must be writeable. I don't know what this behaviour is supposed to be good for.This function copes with the case that the file/directory to be moved or renamed, or the super directories are read only. It makes the necessary places writeable, calls the command, and makes them read only again, if they were before. The user needs the necessary permissions for changing the corresponding write permissions. If an error occurs (such as file not found, or insufficient permissions), then the write permissions are restored to the state before, before the exception is passed through to the caller.The command must take two arguments, the old path and the new path. It is expected to create the new path in the file system, such that the correct write permissions of the new path can be set by  force_cmd after executing it.The new path may be an existing directory. In this case, it is assumed that the old file is to be moved into this directory (like with mv). The new path is completed with the file name component of the old path, before it is passed to the command, such that the command is supplied the complete new path. Examples: cforce_cmd rename from to force_cmd (\from to -> run "/bin/mv" ["-i", "-v", "--", from, to]) from toSee , , .Make a file or directory writeable for the user, perform an action, and restore its writeable status. An IOError is raised when the user doesn't have permission to make the file or directory writeable. Sforce_writeable path io = force_writeable2 path (io >>= \res -> return (path, res))Example: -- Need to create a new directory in /foo/bar, even if that's write protected force_writeable "/foo/bar" $ mkdir "/foo/bar/baz"See , .Make a file or directory writeable for the user, perform an action, and restore its writeable status. The action may change the name of the file or directory. Therefore it returns the new name, along with another return value, which is passed to the caller.DThe writeable status is only changed back if it has been changed by force_writeable2 before. An IOError is raised when the user doesn'h have permission to make the file or directory writeable, or when the new path doesn't exist.See , . Call the fdupes program in order to find identical files. It outputs a list of groups of file names, such that the files in each group are identical. Each of these groups is further analysed by the fdupes action. It is split to a list of lists of paths, such that each list of paths corresponds to one of the directories which have been searched by the fdupesA program. If you just want groups of identical files, then apply  map concat to the result.The fdupes /program doesn't handle multiple occurences of the same directory, or in recursive mode one specified directory containing another, properly. The same file may get reported multiple times, and identical files may not get reported./ The paths are normalised (using  )."EFGHpath7noramlized, absolute path, with symbolic links expandedPath of the symbolic link3The link target - where the symbolic link points topath of the symbolic link)target; where the symbolic link points topath$Whether the path is a symbolic link.path;noramlized, absolute path, with symbolic links not expandedcontents of the symlinkpath of the symlinkblock size, this is the  --block-size option.6path of the file or directory to determine the size ofsize in blockspathpathpathpathNew working directory Action to runCommand line argumentsCommand line argumentssource destinationsource destinationIJfile and block numberOld pathNew pathOld pathNew pathOld pathNew pathOld pathNew path or target directoryOld pathNew path2Command to execute after preparing the permissionsOld pathNew path or target directory#File or directory to make writeableAction to perform&Returns the return value of the action#File or directory to make writeableAction to performOptions for the fdupes program!Directories with files to compare~For each set of identical files, and each of the specified directories, the paths of the identical files in this directory.K"EFGHIJK"EFGHIJKNone !"#/0T Error reporting wrapper for the mainG function. This catches any HsShellScript generated exceptions, and IOError-s, prints an error message and exits with  exitFailure. The main' function typically looks like this: main = mainwrapper $ do ...The exceptions caught are , k,  and IOError. Should be mainWrapped main  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcklmnopqrstuvwxyz{|}~stv|klmnopqrxz{~}yuwL !"#$%&'()*+,--./011233456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxxyz{|}~        0 !"#$ %&'%()%&*#+,-./0123456789:;<=>?@ABCDEFGH I J K L M N O P Q R STUVWXYZ[*hsshellscript-3.4.3-Hv2wc6f8ECcKj7ocP9XLQOHsShellScript.Shell HsShellScriptHsShellScript.PathsHsShellScript.ArgsHsShellScript.GetOptSystem.EnvironmentgetArgsHsShellScript.ProcErrSystem.Posix.ProcessgetProcessStatusHsShellScript.MiscSystem.Posix.Files getFileStatus fileAccessHsShellScript.Commands shell_command shell_quotequote0quoteterminal_widthterminal_width_ioe throwErrno' slice_path unslice_pathnormalise_pathslice_filenameslice_filename'unslice_filename split_pathdir_part filename_part unsplit_path unsplit_partssplit_filenamesplit_filename'unsplit_filenamesplit3unsplit3 test_suffix absolute_pathabsolute_path_byabsolute_path'guess_dotdot_comps guess_dotdotArgErrorargerror_messageargerror_usageinfo ArgumentsArgumentPropertyargumentpropertyArgumentDescriptionargdesc_short_argsargdesc_long_argsargdesc_argarg argdesc_timesargdesc_argargnameargdesc_descriptionargdesc_argarg_tester ArgtesterArgumentValueSpecArgumentValue_noneArgumentValue_requiredArgumentValue_optional is_direct desc_short desc_long desc_directdesc_value_requireddesc_value_optional desc_times desc_oncedesc_at_least_oncedesc_at_most_once desc_at_leastdesc_any_times desc_at_most desc_argnamedesc_description desc_tester readtester desc_integerdesc_nonneg_integerargname argname_a argname_short argname_longargdescgetargsgetargs_orderedgetargs'getargs_ordered' arg_switch arg_timesargs_optargs_req reqarg_opt reqarg_req optarg_opt optarg_req args_noneargs_allargs_oneargs_at_most_oneargs_at_least_one arg_conflicts arg_occurs usage_infounsafe_getargsunsafe_getargs_orderedmake_usage_infoprint_usage_infowrap$fShowArgError$fExceptionArgError$fOrdArgumentDescription$fEqArgumentDescription$fEqArgumentValueSpec$fShowArgumentValueSpec$fOrdArgumentValueSpecRunErrorre_progre_parsre_envre_wdre_psre_errno setFileMode'subproccallspawnrun show_runerrorexplain_processstatusto_ioeas_ioerunprogechoexecexecpexeceexecpe-|-=|--|==|=redirect->-->>-=>-=>>--&>--&>>--<- err_to_out out_to_errpipe_to h_pipe_to pipe_from pipe_from2 h_pipe_from h_pipe_from2lazy_pipe_fromlazy_pipe_from2pipes_exitstrerrorerrnoperror'perrorfailIOexitcode show_ioerror system_throwsystem_runprogsilentlychildoutmoutm_logmlogm_errmerrm_fill_in_filenamefill_in_location add_location execute_fileisattyMntent mnt_fsnamemnt_dirmnt_typemnt_optsmnt_freq mnt_passnozeroschomp lazy_contentscontents path_exists path_exists'is_diris_filegetFileStatus' fileAccess' temp_filetemp_dirtmp_filetmp_dirwith_temp_file with_temp_dir with_tmp_file with_tmp_dir temp_path read_mounts read_mtab read_fstabglob glob_quoterealpathreadlink readlink' is_symlink realpath_ssymlinkdumkdirrmdirrmcdpwdwith_wdchmodchowncpmv mt_statusrename rename_mv force_renameforce_mvforce_rename_mv force_cmdforce_writeableforce_writeable2fdupes mainwrapperArgDescrNoArgReqArgOptArgOptDescrOptionArgOrder RequireOrderPermute ReturnInOrder usageInfogetOptOptKindOptNonOpt EndOfOptsOptErrfmtOptfmtShortfmtLonggetNextlongOptshortOpterrAmbigerrReqerrUnrecerrNoArgArgOccad_tup unlimitedsame_argnulldesc times_default argvalues argerror_uiabort_conflictabortup1 prop_finalgetargs0 test_desc maybe_headoccuringmake_usage_info1 unix-2.7.2.1System.Posix.Process.Commonbase GHC.IO.HandlehSetBinaryModeGHC.IO.Handle.Text hGetContentshCloseSystem.Posix.Process.Internals ProcessStatus $fShowErrnoc_terminal_width hssh_c_isattydup2close c_fcntl_dupfdc_restore_fdflagsc_prepare_fd_flags_for_execc_save_fdflagsforeign_strerror _exit_primc_close_on_exec spawn_locredirect_helper pipe_fork_duphandleToFd_nocloseunsafeWithHandleFdunsafeWithHandleFd' flush_outerrreceive_ioerror send_ioerrorencode_ioerrordecode_ioerror ioe_types ioetype_num num_ioetype$fExceptionProcessStatus$fExceptionRunErrorglobfreedo_glob c_getmntent endmntent setmntentc_mkdirc_closehsshellscript_open_nonvariadico_EXCLo_CREATuntilIOforeign_renameforeign_symlinkhsshellscript_get_readlinkhsshellscript_get_realpathnumberparse_mt_statusreplace_location