summaryrefslogtreecommitdiff
path: root/Utility.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-22 14:57:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-22 14:57:02 -0400
commit91e6625eb56671472abd9532a5635f541d025a60 (patch)
tree5f163e646db6fc3ca6c11c8bfefd4a98f5b382c2 /Utility.hs
parent9ec5d90b6a28e28f6349635d33df0000ce9203ef (diff)
add shellEscape
ugly, but sometimes necessary There is a haskell shell-escape module, but it is not packaged in Debian
Diffstat (limited to 'Utility.hs')
-rw-r--r--Utility.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Utility.hs b/Utility.hs
index 09b973002..8bffde057 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -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