g7X'      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~None stdin for the command to be run )print stdout of command that is executed print command that is executed ShIO is Deprecated in favor of , which is easier to type. %A monadic-conditional version of the when guard. DMakes a relative path relative to the current Sh working directory. % An absolute path is returned as is. ! To create an absolute path, use   +make the second path relative to the first  Uses /, but will canonicalize the paths if necessary >add a trailing slash to ensure the path indicates a directory makes an absolute path.  Like  , but on an exception returns   IObtain a (reasonably) canonic file path to a filesystem object. Based on  canonicalizePath in system-fileio. 8bugfix older version of canonicalizePath (system-fileio <= 0.3.7) loses trailing slash GMake a relative path absolute by combining with the working directory. % An absolute path is returned as is.  To create a relative path, use .  deprecated ,Does a path point to an existing directory?  Does a path point to a symlink? internally log what occurred. # Log will be re-played on failure. ,List directory contents. Does *not* include "." and "..", but it does  include (other) hidden files. )silently uses the Right or Left value of  Filesystem.Path.CurrentOS.toText a print lifted into  a print lifted into  using stderr GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. )A helper to catch any exception (same as  ...  (e :: SomeException) -> ...). /anchor path, the prefix "make this relative to anchor path Left is canonic of second path anchor path, the prefix "make this relative to anchor path anchor path, the prefix "make this relative to anchor path 0 !  None3List directory recursively (like the POSIX utility find). 4 listing is relative if the path given is relative. c If you want to filter out some results or fold over them you can do that with the returned files. F A more efficient approach is to use one of the other find functions. + that filters the found files as it finds. C Files must satisfy the given filter to be returned in the result. 6Fold an arbitrary folding function over files froma a .  Like 3 but use a more general fold rather than a filter. * that filters out directories as it finds b Filtering out directories can make a find much more efficient by avoiding entire trees of files. similar ", but also filter out directories  Alternatively, similar to , but also filter out files > Filtering out directories makes the find much more efficient like 1 but use a folding function rather than a filter > The most general finder: you likely want a more specific one directory filter  file filter  directory   NoneG!9You need to wrap exception handlers with this when using ,. 0Helper to convert a Text to a FilePath. Used by '( /)' and '( .)' /Converter for the variadic argument version of S called #. #"variadic argument version of run. q The syntax is more convenient, but more importantly it also allows the use of a FilePath as a command argument. - So an argument can be a Text or a FilePath. & a FilePath is converted to Text with . 4 You will need to add the following to your module: $ {-# LANGUAGE OverloadedStrings #-} ' {-# LANGUAGE ExtendedDefaultRules #-} - {-# OPTIONS_GHC -fno-warn-type-defaults #-}  import Shelly  import Data.Text.Lazy as LT  default (LT.Text) $Euses System.FilePath.CurrentOS, but can automatically convert a Text %Euses System.FilePath.CurrentOS, but can automatically convert a Text (same as , but use it combinator style *Same as a normal # but specialized for the Sh monad. +Same as a normal  but specialized for the  monad. ,Same as a normal , but specialized for the  monad. -$Catch an exception in the Sh monad. .CChange current working directory of Sh. This does *not* change the G working directory of the process we are running it. Instead, Sh keeps I track of its own working directory and builds absolute paths internally C instead of passing down relative paths. This may have performance D repercussions if you are doing hundreds of thousands of filesystem N operations. You will want to handle these issues differently in those cases. /.W, execute a Sh action in the new directory and then pop back to the original directory :chdir, but first create the directory if it does not exit 0apply a String IO operations to a Text FilePath 0 Currently a  renameFile) wrapper. TODO: Support cross-filesystem F move. TODO: Support directory paths in the second parameter, like in _. 1Get back [Text] instead of [FilePath] 2+Obtain the current (Sh) working directory. 3=exit 0 means no errors, all other codes are error conditions 4&echo a message and exit with status 1 5?for exiting with status > 0 without printing debug information 6fail that takes a Text 78Create a new directory (fails if the directory exists). 8ECreate a new directory, including parents (succeeds if the directory  already exists). 9$Get a full path to an executable on PATH, if exists. FIXME does not  respect setenv'd environment and uses findExecutable which uses the PATH inherited from the process  environment. b FIXME: findExecutable does not maintain a hash of existing commands and does a ton of file stats :%A monadic-conditional version of the  guard. ;4Does a path point to an existing filesystem object? <'Does a path point to an existing file? =KA swiss army cannon for removing things. Actually this goes farther than a K normal rm -rf, as it will circumvent permission problems for the files we  own. Use carefully.  Uses  >9Remove a file. Does not fail if the file does not exist. & Does fail if the file is not a file. ?Remove a file. + Does fail if the file does not exist (use > instead) or is not a file. @ASet an environment variable. The environment is maintained in Sh D internally, and is passed to any external commands to be executed. A,add the filepath onto the PATH env variable J FIXME: only effects the PATH once the process is ran, as per comments in 9 . TODO: use cross-platform searchPathSeparator B4Fetch the current value of an environment variable. 0 if non-existant or empty text, will be Nothing C deprecated DCFetch the current value of an environment variable. Both empty and 7 non-existent variables give empty string as a result. ECFetch the current value of an environment variable. Both empty and @ non-existent variables give the default Text value as a result FECreate a sub-Sh in which external command outputs are not echoed and  commands are not printed.  See J. GACreate a sub-Sh in which external command outputs are echoed and  Executed commands are printed  See J. H/Create a sub-Sh with stdout printing on or off  Defaults to True. I/Create a sub-Sh with command echoing on or off # Defaults to False, set to True by G J-Enter a sub-Sh that inherits the environment @ The original state will be restored when the sub-Sh completes. % Exceptions are propagated normally. K.Create a sub-Sh where commands are not traced  Defaults to True. D You should only set to False temporarily for very specific reasons L9Create a sub-Sh with shell character escaping on or off.  Defaults to True.  Setting to False allows for shell wildcard such as * to be expanded by the shell along with any other special shell characters. M)named after bash -e errexit. Defaults to True.  When True., throw an exception on a non-zero exit code.  When False, ignore a non-zero exit code.  Not recommended to set to False: unless you are specifically checking the error code with [. N)Using this entry point does not create a .shelly directory in the case F of failure. Instead it logs directly into the standard error stream (stderr). OGEnter a Sh from (Monad)IO. The environment and working directories are K inherited from the current process-wide values. Any subsequent changes in G processwide working directory or environment are not reflected in the  running Sh. Qsame as R, but returns () Rrun commands over SSH. - An ssh executable is expected in your path. " Commands are in the same form as S, but given as pairs  > sshPairs "server-name" [("cd", "dir"), ("rm",["-r","dir2"])] /This interface is crude, but it works for now. Please note this sets L3 to False: the commands will not be shell escaped. > Internally the list of commands are combined with the string && before given to ssh. SGExecute an external command. Takes the command name (no shell allowed, 0 just a name of something that can be found via PATH; FIXME: setenv'd  PATH6 is not taken into account when finding the exe name)  and  are collected. The  is returned as  a result of S?, and complete stderr output is available after the fact using  Z 4All of the stdout output will be loaded into memory : You can avoid this but still consume the result by using X, I If you want to avoid the memory and need to process the output then use Y. T0bind some arguments to run for re-use. Example: + monit = command "monit" ["-c", "monitrc"] Ubind some arguments to X for re-use. Example: - monit_ = command_ "monit" ["-c", "monitrc"] VGbind some arguments to run for re-use, and expect 1 argument. Example: : git = command1 "git" []; git "pull" ["origin", "master"] WGbind some arguments to run for re-use, and expect 1 argument. Example: = git_ = command1_ "git" []; git+ "pull" ["origin", "master"] X the same as S , but return () instead of the stdout content 0 stdout will be read and discarded line-by-line Yused by SL. fold over stdout line-by-line as it is read to avoid keeping it in memory [ stderr is still being placed in memory under the assumption it is always relatively small Z)The output of last external command. See S. [%The exit code from the last command.  Unless you set M to False you won'Jt get a chance to use this: a non-zero exit code will throw an exception. \1set the stdin to be used and cleared by the next S. ]LPipe operator. set the stdout the first command as the stdin of the second. O This does not create a shell-level pipe, but hopefully it will in the future. 1 To create a shell level pipe you can always set escaping False and use a pipe | character in a command. ^)Copy a file, or a directory recursively. _ECopy a file. The second path could be a directory, in which case the 0 original file name is used, in that directory. `(A functor-lifting function composition. a@Create a temporary directory and pass it as a parameter to a Sh 1 computation. The directory is nuked afterwards. bWrite a Lazy Text to a file. c=Update a file, creating (a blank file) if it does not exist. dAppend a Lazy Text to a file. e"(Strictly) read file into a Text. $ All other functions use Lazy Text. e Internally this reads a file as strict text and then converts it to lazy text, which is inefficient fwraps ByteSting readFile gflipped hasExtension for Text h6Run a Sh computation and collect timing information. v!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh    i  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiONJFGLHIKMSXY#]Z\[TUVWRQ@BDCEA./2(P1;<9 $%  g0?>=_^78efbdca3456*+!",-&'`:h) m!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh    NoneO /Converter for the variadic argument version of w called . iYou need this when using . k)This type is a simple wrapper for a type  Shelly.Sh.  Sh contains a list of results. lUnpack list of results. m"Pack list of results. It performs concat inside Sh. n;Transform result as list. It can be useful for filtering. oGEnter a Sh from (Monad)IO. The environment and working directories are K inherited from the current process-wide values. Any subsequent changes in G processwide working directory or environment are not reflected in the  running Sh. p Performs shelly and then an empty action  return (). q-Enter a sub-Sh that inherits the environment @ The original state will be restored when the sub-Sh completes. % Exceptions are propagated normally. rBCreate a sub-Sh in which external command outputs are not echoed.  Also commands are not printed.  See sub. s>Create a sub-Sh in which external command outputs are echoed.  Executed commands are printed  See sub. t8Create a sub-Sh with shell character escaping on or off u/Create a sub-Sh with stdout printing on or off v/Create a sub-Sh with command echoing on or off wGExecute an external command. Takes the command name (no shell allowed, 0 just a name of something that can be found via PATH; FIXME: setenv'd  PATH6 is not taken into account when finding the exe name) stdout and stderr are collected. The stdout is returned as  a result of run?, and complete stderr output is available after the fact using   lastStderr 4All of the stdout output will be loaded into memory : You can avoid this but still consume the result by using run_, I If you want to avoid the memory and need to process the output then use  runFoldLines. x The same as run/, but return () instead of the stdout content. yLPipe operator. set the stdout the first command as the stdin of the second. z)The output of last external command. See run. {1set the stdin to be used and cleared by the next run. |&bind some arguments to run for re-use  Example: monit = command monit [-c, monitrc] }bind some arguments to run_ for re-use  Example: monit_ = command_ monit [-c, monitrc] ~=bind some arguments to run for re-use, and expect 1 argument  Example: git = command1 git []; git pull [origin, master] =bind some arguments to run for re-use, and expect 1 argument  Example: git_ = command1_ git []; git+ pull [origin, master] run commands over SSH. - An ssh executable is expected in your path. " Commands are in the same form as w, but given as pairs  > sshPairs "server-name" [("cd", "dir"), ("rm",["-r","dir2"])] /This interface is crude, but it works for now. Please note this sets t3 to False: the commands will not be shell escaped. > Internally the list of commands are combined with the string  &&  before given to ssh. same as , but returns () ASet an environment variable. The environment is maintained in Sh D internally, and is passed to any external commands to be executed. 4Fetch the current value of an environment variable. 0 if non-existant or empty text, will be Nothing CFetch the current value of an environment variable. Both empty and 7 non-existent variables give empty string as a result. CFetch the current value of an environment variable. Both empty and ; non-existent variables give the default value as a result ,add the filepath onto the PATH env variable J FIXME: only effects the PATH once the process is ran, as per comments in  CChange current working directory of Sh. This does *not* change the G working directory of the process we are running it. Instead, Sh keeps I track of its own working directory and builds absolute paths internally C instead of passing down relative paths. This may have performance D repercussions if you are doing hundreds of thousands of filesystem N operations. You will want to handle these issues differently in those cases. cdW, execute a Sh action in the new directory and then pop back to the original directory +Obtain the current (Sh) working directory. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. GEcho text to standard (error, when using _err variants) output. The _n ( variants do not print a final newline. a print lifted into Sh $a print lifted into Sh using stderr same as , but use it combinator style internally log what occured. # Log will be re-played on failure. ,List directory contents. Does *not* include "." and "..", but it does  include (other) hidden files. Get back [Text] instead of [FilePath] 4Does a path point to an existing filesystem object? 'Does a path point to an existing file? ,Does a path point to an existing directory?  Does a path point to a symlink? $Get a full path to an executable on PATH, if exists. FIXME does not  respect setenv'd environment and uses findExecutable which uses the PATH inherited from the process  environment. b FIXME: findExecutable does not maintain a hash of existing commands and does a ton of file stats GMake a relative path absolute by combining with the working directory. % An absolute path is returned as is.  To create a relative path, use path. makes an absolute path.  Like , but on an exception returns path IObtain a (reasonably) canonic file path to a filesystem object. Based on  canonicalizePath in system-fileio. DMakes a relative path relative to the current Sh working directory. % An absolute path is returned as is. ! To create an absolute path, use  +make the second path relative to the first  Uses /, but will canonicalize the paths if necessary  Currently a  renameFile) wrapper. TODO: Support cross-filesystem F move. TODO: Support directory paths in the second parameter, like in cp. Remove a file. + Does fail if the file does not exist (use  instead) or is not a file. 9Remove a file. Does not fail if the file does not exist. & Does fail if the file is not a file. KA swiss army cannon for removing things. Actually this goes farther than a K normal rm -rf, as it will circumvent permission problems for the files we  own. Use carefully.  Uses  removeTree ECopy a file. The second path could be a directory, in which case the 0 original file name is used, in that directory. )Copy a file, or a directory recursively. 8Create a new directory (fails if the directory exists). ECreate a new directory, including parents (succeeds if the directory  already exists). "(Strictly) read file into a Text. $ All other functions use Lazy Text. h So Internally this reads a file as strict text and then converts it to lazy text, which is inefficient Write a Lazy Text to a file. =Update a file, creating (a blank file) if it does not exist. Append a Lazy Text to a file. @Create a temporary directory and pass it as a parameter to a Sh 1 computation. The directory is nuked afterwards. 3List directory recursively (like the POSIX utility find). 4 listing is relative if the path given is relative. c If you want to filter out some results or fold over them you can do that with the returned files. F A more efficient approach is to use one of the other find functions. + that filters the found files as it finds. C Files must satisfy the given filter to be returned in the result. 6Fold an arbitrary folding function over files froma a .  Like 3 but use a more general fold rather than a filter. * that filters out directories as it finds b Filtering out directories can make a find much more efficient by avoiding entire trees of files. similar ", but also filter out directories  Alternatively, similar to , but also filter out files > Filtering out directories makes the find much more efficient like 1 but use a folding function rather than a filter > The most general finder: you likely want a more specific one fail that takes a Text $Catch an exception in the Sh monad. $Catch an exception in the Sh monad. $Catch an exception in the Sh monad. 6Run a Sh computation and collect timing information. +Catch multiple exceptions in the Sh monad. "variadic argument version of run. q The syntax is more convenient, but more importantly it also allows the use of a FilePath as a command argument. - So an argument can be a Text or a FilePath. & a FilePath is converted to Text with . 4 You will need to add the following to your module: $ {-# LANGUAGE OverloadedStrings #-} ' {-# LANGUAGE ExtendedDefaultRules #-} - {-# OPTIONS_GHC -fno-warn-type-defaults #-}  import Shelly  import Data.Text.Lazy as LT  default (LT.Text) p ijklmnopqrstuvwxyz{|}~anchor path, the prefix "make this relative to anchor path directory filter  file filter  directory  !"#$%&'c$%':`gijklmnopqrstuvwxyz{|}~ckpoqrstuvmlnwxyz{|}~$%gij'`:k ijklmnopqrstuvwxyz{|}~ !"#$%&'(    !"#$%&'()*+,-.//0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu//vwx\yWSTYUV`ejgiabcd_^MOQRN;<?$'&%"#5] >HIF=LKJlkDEropqn)*+,-.@AC7:8u9360z{|}~  shelly-0.14.2Shelly Shelly.Pipe Shelly.Base Filesystem stripPrefix Shelly.Findbase Data.Functor<$> Control.Monadunlesswhentransformers-0.3.0.0Control.Monad.IO.ClassliftIOsystem-filepath-0.4.7Filesystem.Path.InternalFilePathShShIOwhenMrelPath relativeTocanonic canonicalizeabsPathpathtest_dtest_sgettracels toTextIgnoreinspect inspect_errechoecho_necho_err echo_n_errcatchanyfindfindWhenfindFold findDirFilterfindDirFilterWhenfindFoldDirFilter ShellyHandlercmd<.> toTextWarnfromTexttagputcatch_sh finally_sh catches_sh catchany_shcdchdirmvlsTpwdexit errorExit quietExitterrormkdirmkdir_pwhichunlessMtest_etest_frm_rfrm_frmsetenv appendToPathget_envgetenv get_env_text get_env_defsilently verbosely print_stdoutprint_commandssubtracingescapingerrExit shellyNoDirshelly show_command sshPairs_sshPairsruncommandcommand_command1 command1_run_ runFoldLines lastStderr lastExitCodesetStdin-|-cp_rcp<$$> withTmpDir writefile touchfile appendfilereadfile readBinaryhasExttimeunrollrollliftShshssStdin sPrintStdoutsPrintCommandsaddTrailingSlashcanonicalizePathControl.Exception.BasecatchStatesCodesStderr sDirectorysRun sEnvironmentsTracingsTracesErrExitunShrunSheitherRelativeTomaybeRelativeTounpackgetsmodifylsRelAbs traceLiftIO>=> text-0.11.2.3Data.Text.Lazy.InternalText ToFilePathShellArgfinallyControl.Exceptioncatcheschdir_ppacksystem-fileio-0.3.10 removeTreeGHC.IO.Handle.FDstdoutstderrReThrownException QuietExit RunFailed ShellyOpts failToDir FoldCallback toFilePath ShellCommandcmdAll toTextArgprintGetContentprintFoldHandleLinesfoldHandleLines runCommandrunCommandNoEscape shellyProcess shellyOptsshelly'readDefsurround sshPairs' foldBuilderliftIO_$fShowReThrownException$fExceptionReThrownException$fExceptionQuietExit$fExceptionRunFailed$fShowRunFailed$fToFilePath[]$fToFilePathText$fToFilePathText0$fToFilePathFilePath$fShellCommand(->)$fShellCommandSh$fShellCommandSh0$fShellCommandSh1$fShellArgFilePath$fShellArgTextsh0sh1sh2sh3sh4sh0ssh1slift1lift2mapM2 $fMonadIOSh $fMonadPlusSh$fApplicativeSh $fMonadSh $fFunctorSh