Escape string for the shell

This commit is contained in:
rnhmjoj 2015-07-07 23:23:32 +02:00
parent bbb9fd83ae
commit c744144b36
2 changed files with 7 additions and 6 deletions

View File

@ -28,5 +28,5 @@ executable skeleton
TypeSynonymInstances TypeSynonymInstances
build-depends: base >=4.8 && <= 5.0, filepath, process, build-depends: base >=4.8 && <= 5.0, filepath, process,
attoparsec, bytestring, hex, time, attoparsec, bytestring, hex, time,
argparser argparser, posix-escape
ghc-options: -O2 ghc-options: -O2

View File

@ -4,10 +4,11 @@ import Skeleton.Types
import Skeleton.Pretty import Skeleton.Pretty
import Skeleton.Parser import Skeleton.Parser
import Control.Monad (when) import Control.Monad (when)
import Data.List (isInfixOf) import Data.List (isInfixOf)
import System.FilePath (takeBaseName) import System.FilePath (takeBaseName)
import System.Process (readProcess, callCommand) import System.Process (readProcess, callCommand)
import System.Posix.Escape (escape)
import System.Console.ArgParser import System.Console.ArgParser
@ -42,7 +43,7 @@ getKeychain paths = do
sendClipboard :: String -> IO () sendClipboard :: String -> IO ()
sendClipboard text = sendClipboard text =
callCommand $ "echo " ++ (show text) ++ " | pbcopy" callCommand $ "echo " ++ (escape text) ++ " | pbcopy"
-- CLI arguments -- -- CLI arguments --