[Shell-escape] Escape toggle with \ prefix
E.g. check file.hs will treat quote characters as literal characters, while \check file.hs will assume quoting behavior Backslash will be dropped, naturally.
This commit is contained in:
parent
fff9087ff7
commit
d49d4cf2ea
@ -36,4 +36,6 @@ go (c:cl) curarg accargs quotes
|
|||||||
| otherwise = go cl (c:curarg) accargs quotes
|
| otherwise = go cl (c:curarg) accargs quotes
|
||||||
|
|
||||||
parseCmdLine :: String -> [String]
|
parseCmdLine :: String -> [String]
|
||||||
parseCmdLine comline = go comline [] [] False
|
parseCmdLine ('\\':comline) = go comline [] [] False
|
||||||
|
parseCmdLine [] = [""]
|
||||||
|
parseCmdLine comline = words comline
|
||||||
|
@ -8,11 +8,17 @@ import Test.Hspec
|
|||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec =
|
spec =
|
||||||
describe "parseCmdLine" $ do
|
describe "parseCmdLine" $ do
|
||||||
it "splits arguments" $
|
it "splits arguments" $ do
|
||||||
parseCmdLine "test command line" `shouldBe` ["test", "command", "line"]
|
parseCmdLine "test command line" `shouldBe` ["test", "command", "line"]
|
||||||
it "honors quoted segments" $
|
parseCmdLine "\\test command line" `shouldBe` ["test", "command", "line"]
|
||||||
parseCmdLine "test command line \STXwith quoted segment\ETX"
|
it "honors quoted segments if turned on" $
|
||||||
|
parseCmdLine "\\test command line \STXwith quoted segment\ETX"
|
||||||
`shouldBe` ["test", "command", "line", "with quoted segment"]
|
`shouldBe` ["test", "command", "line", "with quoted segment"]
|
||||||
it "squashes multiple spaces" $
|
it "doesn't honor quoted segments if turned off" $
|
||||||
|
parseCmdLine "test command line \STXwith quoted segment\ETX"
|
||||||
|
`shouldBe` words "test command line \STXwith quoted segment\ETX"
|
||||||
|
it "squashes multiple spaces" $ do
|
||||||
parseCmdLine "test command"
|
parseCmdLine "test command"
|
||||||
`shouldBe` ["test", "command"]
|
`shouldBe` ["test", "command"]
|
||||||
|
parseCmdLine "\\test command"
|
||||||
|
`shouldBe` ["test", "command"]
|
||||||
|
Loading…
Reference in New Issue
Block a user