{-# LANGUAGE OverloadedStrings #-}
import Turtle
runSh :: Text -> IO ()
runSh x = view $ inshell x empty
main :: IO ()
main = do
runSh "echo 'abcxyz'"
I've got the above program which outputs:
Line "abcxyz"
Is there a way I can capture this text without being output to the shell's stdout?
Essentially, I'd like to run the process and get a [Line]
value rather then a ()
value from the IO
action.
This is possible with shellStrictWithErr.
{-# LANGUAGE OverloadedStrings #-}
import Turtle (empty, shellStrictWithErr, ExitCode)
import Data.Text (Text)
runSh :: Text -> IO (ExitCode, Text, Text)
runSh x' = shellStrictWithErr x' empty
main :: IO ()
main = do
(e, v, v') <- runSh "ls"
print e
print v
print v'