X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=utils%2Fpwd%2Fpwd.hs;h=694941643dec9561ef3d21c6d00f2136c37bba42;hp=45a2d462703b7e80237c863c2b81c05e84f13464;hb=9000c679a8904a398022b96e01649120e024c615;hpb=1e9af42caa0949ae05e5e2db5250227e86196e19 diff --git a/utils/pwd/pwd.hs b/utils/pwd/pwd.hs index 45a2d46..6949416 100644 --- a/utils/pwd/pwd.hs +++ b/utils/pwd/pwd.hs @@ -9,24 +9,14 @@ import System.IO main :: IO () 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 + case args of + [] -> do d <- getCurrentDirectory + putStr $ map forwardifySlashes d + _ -> do hPutStrLn stderr ("Bad args: " ++ show args) + hPutStrLn stderr "Usage: pwd" + exitFailure --- In prog006 we have to escape \ twice, once to get through sed and --- again to get through parsing pkg.conf -escape_quadruple_backslash :: Char -> String -escape_quadruple_backslash '\\' = "\\\\\\\\" -escape_quadruple_backslash c = [c] - --- Normally we can get away with just replacing backslashes with forwardslashes -escape_forwardslash :: Char -> String -escape_forwardslash '\\' = "/" -escape_forwardslash c = [c] +forwardifySlashes :: Char -> Char +forwardifySlashes '\\' = '/' +forwardifySlashes c = c