Peter Hall Peter Hall - 6 months ago 41
Bash Question

Is it possible to invoke bash or shell scripts from a haskell program?

I'm writing some shell scripts with haskell, which I'm running in gitbash, but there are a few other existing scripts I'd like to be able to use from those scripts.

For example, I'd like to run maven goals or do a git pull, but without having to integrate specifically with those tools.

Is there a way to do this?


You can use System.Process. For example, executing seq 1 10 shell command:

> import System.Process

> readProcess "seq" ["1", "10"] ""
it :: String

> readProcessWithExitCode  "seq" ["1", "10"] ""
it :: (GHC.IO.Exception.ExitCode, String, String)