summaryrefslogtreecommitdiff
path: root/libraries/base/tests/System/getEnv001.hs
blob: b30db0fb51d05171b68fc76422441449ed0c2ab5 (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