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