| > How do you easily fork to run a command in the background? `turtle` provides `fork` for running a command in the background. Example usage: example = do
using (fork commandToForkInAnotherThread)
theseCommandsStillRunInTheOriginalThread
> How does setting up pipes work?See the `inproc` and `inshell` commands, which let you convert any shell command into a stream transformation embedded within Haskell. > What's the idiom for chdir'ing to a subdirectory such that you pop back out again when you're done (I'd use a subshell with (ch xxx; ...) in bash)? You can write a combinator for this using `turtle` pretty easily: pushd newDir = do
oldDir <- pwd
cd newDir
return (cd oldDir)
... and you use it like this: example = do
popDir <- pushDir "/tmp"
... do stuff ...
popDir
> what's the equivalent of <() in bash?`inproc`/`inshell` which let you read in a command's standard output as a stream |
<(foo) in bash creates a fifo, and pipes the output of foo to the fifo. It then replaces the whole <(foo) argument with the path to the fifo. This means that commands that normally expect to read from a file on the command line can instead be wired to read their input from a process. And, of course, both processes run concurrently.
>(foo) does the same thing, except the other way around, for process output.