)v      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu  Safe-InferedvvNoneRemove tmp on run success? Remove tmp on run error? Stream for env text. Stream for run text. Data unpacking text.  w    w Safe-InferedHA chunk describes a block of binary data ready for inclusion in a shell N script. For many data blocks, no encoding or decoding is necessary; these  are stored in a ,. Those blocks needing byte-translation are  stored in an .  Converts a x2 into a string safe for inclusion in a shell HERE M document and annotates with information to construct a shell decoder for ! that document, if necessary. A x: with nulls is rewritten in a complicated way. Two escape O characters are chosen from a class of ASCII printable characters that look M like reasonable escape characters; the two that show up least frequently I in the document (including 0 times) become the null replacer and the K escaper. All instances of these two characters are rewritten to escape M sequences formed with the escaper, while nulls are rewritten to the null H replacer. Given the two characters thus chosen, a command line with tr  and sed8 in sequence can be constructed to decode the document. AThis encoding doubles the amount of space consumed by the escape N characters. In the worst case, where the data is made of all 20 potential 8 escapes, evenly distributed, and one null (so we can't punt on escaping), K the data will grow in size by 10 percent. For data that is more evenly O distributed over the bytes -- as we might expect of compressed tarballs -- E we expect a size growth of two 256ths, or less than 0.8 percent. IGiven a byte to replace nulls and an escape byte, rewrites the data such M that nulls are mapped to the replace byte, replace bytes are mapped to a L pair of escape bytes and the escape byte is is mapped to an escape byte H followed by an underscore. For example, if the null replace byte is !  and the escape byte is # then all nulls become !, any ! become  ## and all # become #_. KThis escaping scheme is dictated by the needs of our Sed decoder, which is N just two global substitions, one after another. If the escaping were such % that, with our characters above, # escaped to ## and ! to #_,  then #_ in the input becomes ##_!. We want to run the subsitution  for ## first, to catch this; it produces #_; then Sed feeds the input ; to the second substitution which unfortunately renders ! . In the + alternate scheme, the input is encoded #__, the ! decoder runs first  and ignores it, then the #+ decoder runs and catches it. When using a O pipeline of stream processors to interpret escape sequences, it seems best N to ensure that only the very last processor inserts escape characters, to * prevent their further interpretation. LGiven the byte used to replace nulls and the escape byte, undoes the result M of the encode operation -- rewriting null replacers to literal nulls and O escape patterns to the original bytes. This function is not intended to be N used in practice -- it will be shell commands that unpack the data -- but N serves to document the ideas behind decoding as well as offering a way to  check the encoder. JThe candidate escape characters, with the forms to be used in constructed  tr and sed commands. JMany binary strings can be embedded as-is in a HEREDOC, without escaping. JPredicate to determine whether data is represented as an encoded chunk or  is unencoded. ;Finds a short hexadecimal string that is not in the input. A string of length n has at most  n - (k - 1) substrings of some fixed,  positive length k1 -- the substring starting at the first byte and  extending for k:, the substring starting at the second byte and extending  for k3 and so on, on until the end where we have to stop k - 1 short of  the last byte. We choose k* such that it contains enough hexadecimal D digits to enumerate all the substrings; for a 4M input, we want k = 6. -We can take all the hex substrings of length k in the input, sort them, M and then find the gaps. We take the least substring in the first gap for A our chosen substring. This gives us an O(n log n) algorithm. The measurable length of a x is at most the maximum y - (since the length function results in an z); this is one less than 2  to the bit width of a y (because there is a 0 y ). Thus a y ; suffices to enumerate all the possible substrings in a x; and L one more. (Substrings are zero-indexed and the length is 1-indexed.) We : can leverage this fact to translate all substrings to y and store J them in an unboxed vector, using integer operations to find the least J subtring in the first gap. Space usage is linear in the length of the M input string; for a 4M string, the sorted vector could consume 32M on 64  bit machines.  {     { Safe-Infered:Non-overlapping classes of command line argument strings. A # is a decimal number followed by a + multiplicative suffix, in the manner of dd  or head%. Note that counts in terms of bytes  require B (unlike dd or head ). For a  full list of suffixes, see 0 below. A  is a string of decimal digits:  123123. A  is a sequence of hexadecimal / digits, upper or lower case, beginning with  0x; for example: 0x01a3. A ! is a scheme, separated from the 1 resource, represented as an arbitrary string,  by : . The scheme consists of ASCII, - lower-case letters and digits, and may be - multi-part, with each part separated by a +  or / (for example, git+ssh). An example  URL: http: example.com/ ?q=special. A  is a beginning with a dash and  then at least one non-dash. A  is a single dash, -, commonly used  to indicate input from stdin or output to  stdout. A   is a string beginning with two * dashes and then at least one non-dash. !A ! is a string of two dashes, --, 0 commonly used to indicate the end of options  processing. "A " is a file path starting with  @, @., or ../. #An # has the form   shell var name= string. For example,  SENDIN=the_clowns. $Determine if a particular x matches the given  of token. %Determine if a particular x matches any  of token. &4A ByteString stand-in that demoes each token class. 'IThe recognizer appropriate to each token class. Parses successfully if a - the token class is recognized, returning '()'. Most token types are > defined in terms of a prefix of the input -- for example, " O -- and the parsers for these tokens naturally return as soon as the prefix  is recognized. 0HA map from suffixes to sizes, following the conventions of command line  tools (GNU dd or head. and many others) as well as the standard for ) binary sizes established by the IEC.   B = 1  K = KiB = 1024B kB = 1000B  M = MiB = 1024K MB = 1000kB  G = GiB = 1024M GB = 1000MB  T = TiB = 1024G TB = 1000GB  P = PiB = 1024T PB = 1000TB  E = EiB = 1024P EB = 1000PB  Z = ZiB = 1024E ZB = 1000EB  Y = YiB = 1024Z YB = 1000ZB  11Parse a size, consuming the entire input string. 2GParse a size, consuming the entire input string, with the final result  bounded by the maximum of a | type.  !"#$%&'()*+,-./012 !"#$%&'()*+,-./012#"! $%&'()*+,-./012 #"! $%&'()*+,-./012 Safe-Infered3Handled styles of Tar archive. 7'Scan a lazy ByteString for file magic. 3456789:3456789:3654789:3654789: Safe-Infered?IValid shell variable names consist of a leading letter or underscore and 7 then any number of letters, underscores or digits. @5Valid shell string values contain any byte but null. ;<=>?@ABC}~ ;<=>?@ABC @B?CA=>;< ;<=>?@ABC}~ Safe-InferedE.A source of bytes (no writing, only reading). HIA byte-oriented store that can be read from or written to in a streaming  fashion. DEFGHIJKLMNOPQRSTUVWXYZ[DEFGHIJKLMNOPQRSTUVWXYZ[KLMNOPQRSTHJIEGFDUVWXYZ[DEGFHJIKLMNOPQRSTUVWXYZ[ Safe-Infered\A \? program archives streams to produce a script that unpacks the M file data in a temporary location and runs the command with the attached E environment information in that location. The command may be any H executable file contents, modulo architectural compatibility. It is J written along side the temporary work location, to ensure it does not K collide with any files in the archive. The two boolean flags determine N when to delete the temporary directory. The first flag determines whether M or not to delete successful (exit code zero) runs; the second determines ? whether or not to delete failed (exit code non-zero) runs. ^An ^? program processes byte streams with the specified chunking to  produce a script. `8ARX subprograms process some input to produce a script. \]^_`a\]^_`a`a^_\]\]^_`a  Safe-Infered34567?@BC\]^_`a`a^_\]@B?C36547 Safe-Inferedf0Run CLI tool, processing arguments and options. g.Apply defaulting and overrides appropriate to ^ programs. i.Apply defaulting and overrides appropriate to \ programs. pDBy default, we encode binary data to HERE docs 4MiB at a time. (The G encoded result may be up to 10% larger, though 1% is more likely.) q$The default task is a no-op call to /bin/true. bcdefghijklmnopqrstubcdefghijklmnopqrstufghijklmnopqbedcrstubedcfghijklmnopqrstu     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNONPQRSTUVWXYZ[\]^_`abbccdefghijklmnopqrstuvwxy z{|}O~~ arx-0.1.1System.Posix.ARX.TMPXToolsSystem.Posix.ARX.HEREDatSystem.Posix.ARX.CLI.CLTokensSystem.Posix.ARX.TarSystem.Posix.ARX.ShSystem.Posix.ARX.CLI.OptionsSystem.Posix.ARX.ProgramsSystem.Posix.ARX.CLISystem.Posix.ARX.BlazeIsStringSystem.Posix.ARXTemplaterm0rm1envrundatrender findChunkscoalesce markHolesisHole EscapeCharChunk EncodedChunk SafeChunkchunkencodedecodeescapessafeForHereDocencodedscriptleastStringNotInClassSize DecimalNumHexNumURL ShortOptionDash LongOptionDashDash QualifiedPath EnvBindingmatch recognizeexemplar recognizerschemeSeparatorvarFirstvarBodyisLongOptionCharisShortOptionChar isSchemeChar isHexDigitisURLSchemeCharsizessize sizeBoundedTarTBZTGZTARmagicbzMagicgzMagictarMagicRawrawRenderVarValsetEUvalvar ArgsParser ByteSourceIOStream ByteStringPathSTDIOshdattmpx blockSize outputFileioStreamqPathrm scriptToRuncmdsatisfyanyArgargargPrim<@>tokCLslashesTMPXSHDATARX interpretZOMManyOneZeromain shdatResolveshdatCheckStreams tmpxResolvetmpxCheckStreamstmpxOpenopenByteSource inIOStream outIOStream arIOStream defaultBlock defaultTaskstreamsMessage blockMessageerrdie$fIsStringBuilder$fShowTemplatebytestring-0.9.2.1Data.ByteString.InternalbaseGHC.WordWordghc-prim GHC.TypesInt$fIsStringChunkGHC.EnumBounded $fRender[] $fRender[]0$fRawVar $fRenderVar$fRawVal $fRenderVal $fARXTMPX[]$fARXSHDATByteString $fMonoidZOM