Skip to content

Commit adc483c

Browse files
authored
Merge pull request haskell#4418 from hvr/pr/issue-4414-splitArgs
Add minimal support for escaping `"`s to splitArgs
2 parents 8d3e120 + c0d0ff0 commit adc483c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Cabal/Distribution/Simple/Setup.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,8 +2245,11 @@ configureProg verbosity programDb prog = do
22452245
-- | Helper function to split a string into a list of arguments.
22462246
-- It's supposed to handle quoted things sensibly, eg:
22472247
--
2248-
-- > splitArgs "--foo=\"C:\Program Files\Bar\" --baz"
2249-
-- > = ["--foo=C:\Program Files\Bar", "--baz"]
2248+
-- > splitArgs "--foo=\"C:/Program Files/Bar/" --baz"
2249+
-- > = ["--foo=C:/Program Files/Bar", "--baz"]
2250+
--
2251+
-- > splitArgs "\"-DMSGSTR=\\\"foo bar\\\"\" --baz"
2252+
-- > = ["-DMSGSTR=\"foo bar\"","--baz"]
22502253
--
22512254
splitArgs :: String -> [String]
22522255
splitArgs = space []
@@ -2261,6 +2264,7 @@ splitArgs = space []
22612264
string :: String -> String -> [String]
22622265
string w [] = word w []
22632266
string w ('"':s) = space w s
2267+
string w ('\\':'"':s) = string ('"':w) s
22642268
string w ( c :s) = string (c:w) s
22652269

22662270
nonstring :: String -> String -> [String]

0 commit comments

Comments
 (0)