add shellEscape

ugly, but sometimes necessary

There is a haskell shell-escape module, but it is not packaged in Debian
This commit is contained in:
Joey Hess 2010-10-22 14:57:02 -04:00
parent 9ec5d90b6a
commit 91e6625eb5

View file

@ -7,7 +7,8 @@ module Utility (
parentDir,
relPathCwdToDir,
relPathDirToDir,
boolSystem
boolSystem,
shellEscape
) where
import System.IO
@ -108,3 +109,9 @@ boolSystem command params = do
ExitFailure e -> if Just e == cast sigINT
then error $ command ++ "interrupted"
else return False
{- Escapes a filename to be safely able to be exposed to the shell. -}
shellEscape f = "'" ++ quote ++ "'"
where
-- replace ' with '"'"'
quote = join "'\"'\"'" $ split "'" f