[Shell-escape] 'ascii-escape ' prefix toggle
This commit is contained in:
parent
d49d4cf2ea
commit
849496c047
@ -16,6 +16,7 @@
|
|||||||
module GHCMod.Options.ShellParse (parseCmdLine) where
|
module GHCMod.Options.ShellParse (parseCmdLine) where
|
||||||
|
|
||||||
import Data.Char
|
import Data.Char
|
||||||
|
import Data.List
|
||||||
|
|
||||||
go :: String -> String -> [String] -> Bool -> [String]
|
go :: String -> String -> [String] -> Bool -> [String]
|
||||||
-- result
|
-- result
|
||||||
@ -36,6 +37,8 @@ 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'
|
||||||
|
| Just comline <- stripPrefix "ascii-escape " $ dropWhile isSpace comline'
|
||||||
|
= go (dropWhile isSpace comline) [] [] False
|
||||||
parseCmdLine [] = [""]
|
parseCmdLine [] = [""]
|
||||||
parseCmdLine comline = words comline
|
parseCmdLine comline = words comline
|
||||||
|
@ -10,9 +10,9 @@ spec =
|
|||||||
describe "parseCmdLine" $ do
|
describe "parseCmdLine" $ do
|
||||||
it "splits arguments" $ do
|
it "splits arguments" $ do
|
||||||
parseCmdLine "test command line" `shouldBe` ["test", "command", "line"]
|
parseCmdLine "test command line" `shouldBe` ["test", "command", "line"]
|
||||||
parseCmdLine "\\test command line" `shouldBe` ["test", "command", "line"]
|
parseCmdLine "ascii-escape test command line" `shouldBe` ["test", "command", "line"]
|
||||||
it "honors quoted segments if turned on" $
|
it "honors quoted segments if turned on" $
|
||||||
parseCmdLine "\\test command line \STXwith quoted segment\ETX"
|
parseCmdLine "ascii-escape test command line \STXwith quoted segment\ETX"
|
||||||
`shouldBe` ["test", "command", "line", "with quoted segment"]
|
`shouldBe` ["test", "command", "line", "with quoted segment"]
|
||||||
it "doesn't honor quoted segments if turned off" $
|
it "doesn't honor quoted segments if turned off" $
|
||||||
parseCmdLine "test command line \STXwith quoted segment\ETX"
|
parseCmdLine "test command line \STXwith quoted segment\ETX"
|
||||||
@ -20,5 +20,10 @@ spec =
|
|||||||
it "squashes multiple spaces" $ do
|
it "squashes multiple spaces" $ do
|
||||||
parseCmdLine "test command"
|
parseCmdLine "test command"
|
||||||
`shouldBe` ["test", "command"]
|
`shouldBe` ["test", "command"]
|
||||||
parseCmdLine "\\test command"
|
parseCmdLine "ascii-escape test command"
|
||||||
|
`shouldBe` ["test", "command"]
|
||||||
|
it "ingores leading spaces" $ do
|
||||||
|
parseCmdLine " test command"
|
||||||
|
`shouldBe` ["test", "command"]
|
||||||
|
parseCmdLine " ascii-escape test command"
|
||||||
`shouldBe` ["test", "command"]
|
`shouldBe` ["test", "command"]
|
||||||
|
Loading…
Reference in New Issue
Block a user