git @ Cat's Eye Technologies The-Dipple / master haskell / system.hs
master

Tree @master (Download .tar.gz)

system.hs @masterraw · history · blame

module Main where

-- SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
-- For more information, please refer to <https://unlicense.org/>
-- SPDX-License-Identifier: Unlicense

import System.IO
import System.Process

cat handle = do
    eof <- hIsEOF handle
    if
        eof
      then do
        return ()
      else do
        line <- hGetLine handle
        putStr ">>>"
        putStr line
        putStrLn "<<<"
        cat handle

main =
    let
        cmd = (shell "ls -la *.hs"){ std_out = CreatePipe }
    in do
        (_, Just hStdout, _, proc) <- createProcess cmd
        cat hStdout
        exitCode <- waitForProcess proc
        putStrLn (show exitCode)
        return ()