summaryrefslogtreecommitdiff
path: root/libraries/base/tests/System/system001.hs
blob: 7d5c0bde935269b2c089b475dadc8ff3427c43f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- Not run on mingw, because of /dev/null use

import System.Cmd (system)
import System.Exit (ExitCode(..), exitWith)

main = do ec <- system "cat dog 1>/dev/null 2>&1"
          case ec of
              ExitSuccess ->
                  do putStr "What?!?\n"
                     ioError (userError "dog succeeded")
              ExitFailure _ ->
                  do ec <- system "cat system001.hs 2>/dev/null"
                     case ec of
                         ExitSuccess ->
                             exitWith ExitSuccess
                         ExitFailure _ ->
                             do putStr "What?!?\n"
                                ioError (userError "cat failed")