summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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