shebanger-1.0.0.0: Transform a shell script into a series of scripts with only shebang lines
Safe HaskellSafe-Inferred
LanguageHaskell2010

Shebanger

Synopsis

Documentation

We need things from QuickCheck for some of the tests.

>>> import Test.QuickCheck

inputScriptChunkLength :: Int Source #

The length of chunks of the input script.

The input script will be chunked into parts of this many bytes, then base-64 encoded (which increases the length by about 33%). This base-64-encoded string will then be put into the shebang line of all the shebanged scripts.

Note that Linux has a limit on how long a shebang line can be, so in practice this has to be below 150 characters or so.

getShebangedIndex :: FilePath -> Either String Int Source #

Returns Left String of the last part of the filename that it is trying to parse a number on error.

Returns Right Int with the index if it is found correctly.

split :: forall a. (a -> Bool) -> [a] -> NonEmpty [a] Source #

Split a list based on a predicate.

>>> split (== ' ') "hello world my name is bob"
"hello" :| ["world","my","name","is","bob"]

A predicate of const True splits on everything, leaving you with a list of empty lists, with one more entry than your original list:

>>> split (const True) "bye"
"" :| ["","",""]

A predicate of const False produces no splits:

>>> split (const False) "bye"
"bye" :| []

An empty list doesn't get split, regardless of the predicate:

\(Fun _ f) -> split f "" == ("" :| [])