diff options
Diffstat (limited to 'testsuite/tests/lib/System/getEnv001.hs')
-rw-r--r-- | testsuite/tests/lib/System/getEnv001.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/tests/lib/System/getEnv001.hs b/testsuite/tests/lib/System/getEnv001.hs new file mode 100644 index 0000000000..745f8eaa7f --- /dev/null +++ b/testsuite/tests/lib/System/getEnv001.hs @@ -0,0 +1,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 |