diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/pwd/Makefile | 18 | ||||
-rw-r--r-- | utils/pwd/pwd.hs | 26 |
2 files changed, 44 insertions, 0 deletions
diff --git a/utils/pwd/Makefile b/utils/pwd/Makefile new file mode 100644 index 0000000000..326c707641 --- /dev/null +++ b/utils/pwd/Makefile @@ -0,0 +1,18 @@ + +# We don't include any of the boilerplate Makefiles as we are used +# by configure. GHC should be overridden on the command line to the +# GHC that you want to use. + +GHC=ghc + +.PHONY: all clean + +all: + $(GHC) --make pwd + +clean: + rm -f *.o + rm -f *.hi + rm -f pwd + rm -f pwd.exe + diff --git a/utils/pwd/pwd.hs b/utils/pwd/pwd.hs new file mode 100644 index 0000000000..264cc982e9 --- /dev/null +++ b/utils/pwd/pwd.hs @@ -0,0 +1,26 @@ + +module Main where + +import System.Directory +import System.Environment + +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 + +-- 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] + |