summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/System/getEnv001.hs
blob: 745f8eaa7f20a6bb86e393c1781a281cb9cad754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

import System.Environment (getEnv)
import System.IO.Error (catchIOError, isDoesNotExistError)

main :: IO ()
main = do
    term <- getEnv "PATH"
    putStrLn "Got $PATH"
    fish <- getEnv "One fish, two fish, red fish, blue fish" `catchIOError` getEnv_except
    putStrLn fish

getEnv_except :: IOError -> IO String
getEnv_except ioe
 | isDoesNotExistError ioe = return ""
 | otherwise		   = ioError ioe