Idris2/tests/base/system_file_popen/Popen.idr
2021-11-05 11:59:17 +00:00

22 lines
636 B
Idris

import Data.String
import System.File
import System.Info
main : IO ()
main = do
Right f <- popen ("echo " ++ escapeArg "Hello, world") Read
| Left err => printLn err
Right contents <- fGetLine f
| Left err => printLn err
printLn $ trim contents
let cmd : List String = if not isWindows
then ["printf", "Hello, %s", "$PATH"]
else ["echo", "Hello, $PATH"]
Right f <- popen cmd Read
| Left err => printLn err
Right contents <- fGetLine f
| Left err => printLn err
printLn $ (ifThenElse isWindows trim id) contents