4 import System.Directory
5 import System.Environment
12 escape <- case args of
13 ["quadruple-backslash"] -> return escape_quadruple_backslash
14 ["forwardslash"] -> return escape_forwardslash
15 _ -> do hPutStrLn stderr ("Bad args: " ++ show args)
17 "Usage: pwd {forwardslash|quadruple-backslash}"
19 d <- getCurrentDirectory
20 putStr $ concatMap escape d
22 -- In prog006 we have to escape \ twice, once to get through sed and
23 -- again to get through parsing pkg.conf
24 escape_quadruple_backslash :: Char -> String
25 escape_quadruple_backslash '\\' = "\\\\\\\\"
26 escape_quadruple_backslash c = [c]
28 -- Normally we can get away with just replacing backslashes with forwardslashes
29 escape_forwardslash :: Char -> String
30 escape_forwardslash '\\' = "/"
31 escape_forwardslash c = [c]