From: Ian Lynagh Date: Fri, 4 Jul 2008 23:33:43 +0000 (+0000) Subject: Improve error messages from pwd X-Git-Tag: Before_cabalised-GHC~79 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=ec05d3bbba14c9c022a9752819f7fd4aa9277e1c;hp=d5962639234c30fbfca3fa5845c8a03686bb8fb0;p=ghc-hetmet.git Improve error messages from pwd --- diff --git a/utils/pwd/pwd.hs b/utils/pwd/pwd.hs index 264cc98..45a2d46 100644 --- a/utils/pwd/pwd.hs +++ b/utils/pwd/pwd.hs @@ -3,15 +3,21 @@ module Main where import System.Directory import System.Environment +import System.Exit +import System.IO main :: IO () -main = do args <- getArgs - let escape = case args of - ["quadruple-backslash"] -> escape_quadruple_backslash - ["forwardslash"] -> escape_forwardslash - _ -> error ("pwd: Bad args: " ++ show args) - d <- getCurrentDirectory - putStr $ concatMap escape d +main = do + args <- getArgs + escape <- case args of + ["quadruple-backslash"] -> return escape_quadruple_backslash + ["forwardslash"] -> return escape_forwardslash + _ -> do hPutStrLn stderr ("Bad args: " ++ show args) + hPutStrLn stderr + "Usage: pwd {forwardslash|quadruple-backslash}" + exitFailure + d <- getCurrentDirectory + putStr $ concatMap escape d -- In prog006 we have to escape \ twice, once to get through sed and -- again to get through parsing pkg.conf