shell-escape 0.1.1 → 0.1.2
raw patch · 6 files changed
+22/−19 lines, 6 filessetup-changed
Files
- Makefile +1/−1
- Setup.hs +3/−1
- Text/ShellEscape/Bash.hs +2/−0
- Text/ShellEscape/Sh.hs +1/−1
- shell-escape.cabal +1/−1
- test/Echo.hs +14/−15
Makefile view
@@ -30,7 +30,7 @@ test/echo: test/Echo.hs mkdir -p test/build- ${GHC} test/build -O2 test/Echo.hs -o test/echo+ ${GHC} test/build test/Echo.hs -o test/echo .PHONY: test_run test_run: test/echo
Setup.hs view
@@ -1,2 +1,4 @@ import Distribution.Simple-main = defaultMain++main = defaultMain+
Text/ShellEscape/Bash.hs view
@@ -68,6 +68,8 @@ | c <= 'Z' = Literal | c == '[' = Quoted | c == '\\' = ANSIBackslash+ | c <= ']' = Quoted+ | c == '_' = Literal | c <= '`' = Quoted | c <= 'z' = Literal | c <= '~' = Quoted
Text/ShellEscape/Sh.hs view
@@ -39,7 +39,7 @@ -} act :: EscapingMode -> (Char, EscapingMode) -> (Put.Put, EscapingMode) act Quote (c, Quote) = (Put.putChar c , Quote)-act Quote (c, Literal) = (Put.putString ['\'', c] , Literal)+act Quote (c, Literal) = (Put.putChar c , Quote) act Quote (c, Backslash) = (Put.putString ['\'', '\\', c] , Literal) act Backslash (c, Backslash) = (Put.putChar c , Literal) act Backslash (c, Quote) = (Put.putString ['\\', '\'', c] , Quote)
shell-escape.cabal view
@@ -1,5 +1,5 @@ name : shell-escape-version : 0.1.1+version : 0.1.2 category : Text license : BSD3 license-file : LICENSE
test/Echo.hs view
@@ -3,12 +3,13 @@ import System.Environment import System.Process (runInteractiveProcess, waitForProcess, ProcessHandle)-import System.IO (Handle, stderr, stdout, stdin)-import Data.ByteString (ByteString, pack, hGetContents, hPutStrLn)+import System.IO (Handle, stderr, stdout, stdin, hClose)+import Data.ByteString (ByteString, pack, hGetContents) import qualified Data.ByteString-import Data.ByteString.Char8 (unpack)+import Data.ByteString.Char8 (unpack, hPutStrLn) import qualified Data.ByteString.Char8 as Char8 import Data.Word+import Control.Applicative import Control.Monad import qualified Text.Printf import Data.IORef@@ -17,7 +18,7 @@ import Test.QuickCheck import Test.QuickCheck.Monadic -import Text.ShellEscape+import Text.ShellEscape hiding (sh, bash) -- It is best to implement the echo test with `printf':@@ -35,10 +36,9 @@ printf escaped = do (i, o, e, p) <- shell escaped cmd exit <- waitForProcess p- hGetContents o+ hGetContents o <* mapM_ hClose [i, o, e] where- cmd = "printf '%s' " ++ unpack raw- raw = bytes escaped+ cmd = "printf '%s' " ++ unpack (bytes escaped) prop_echoBash :: ByteString -> Property@@ -94,13 +94,12 @@ instance Arbitrary ByteString where arbitrary = do- bytes <- arbitrary :: Gen [Word8]- NonEmpty bytes' <- arbitrary :: Gen (NonEmptyList Word8)- pack `fmap` elements [bytes', bytes', bytes, bytes', bytes']--instance Arbitrary Word8 where- arbitrary = fmap fromIntegral (choose ( 0x01 :: Int- , 0xFF :: Int ))+ bytes <- arbitrary :: Gen [NonZero Word8]+ NonEmpty bytes' <- arbitrary :: Gen (NonEmptyList (NonZero Word8))+ pack `fmap` elements+ (fmap unNonZero `fmap` [bytes', bytes', bytes, bytes', bytes'])+ where+ unNonZero (NonZero t) = t main = do runSh <- newIORef True@@ -120,7 +119,7 @@ _ -> error "Invalid arguments." tests <- readIORef testsR let msg = "Performing " ++ show tests ++ " tests."- qcArgs = Args Nothing tests tests 32+ qcArgs = Args Nothing tests tests 32 False qc = quickCheckWith qcArgs err "Tests are random ByteStrings, containing any byte but null." runSh ?> do