4 import System.Directory
5 import System.Environment
8 main = do args <- getArgs
9 let escape = case args of
10 ["quadruple-backslash"] -> escape_quadruple_backslash
11 ["forwardslash"] -> escape_forwardslash
12 _ -> error ("pwd: Bad args: " ++ show args)
13 d <- getCurrentDirectory
14 putStr $ concatMap escape d
16 -- In prog006 we have to escape \ twice, once to get through sed and
17 -- again to get through parsing pkg.conf
18 escape_quadruple_backslash :: Char -> String
19 escape_quadruple_backslash '\\' = "\\\\\\\\"
20 escape_quadruple_backslash c = [c]
22 -- Normally we can get away with just replacing backslashes with forwardslashes
23 escape_forwardslash :: Char -> String
24 escape_forwardslash '\\' = "/"
25 escape_forwardslash c = [c]