Cope with libraries in libraries/foo/bar rather than just libraries/foo
[ghc-hetmet.git] / utils / pwd / pwd.hs
1
2 module Main where
3
4 import System.Directory
5 import System.Environment
6
7 main :: IO ()
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
15
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]
21
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]
26