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:
parent
9ec5d90b6a
commit
91e6625eb5
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue