[GHC] #8802: createProcess implictlitly escapes and quotes command line parameters
GHC
ghc-devs at haskell.org
Thu Feb 20 08:11:57 UTC 2014
#8802: createProcess implictlitly escapes and quotes command line parameters
--------------------------------------+------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: high | Milestone: 7.8.1
Component: libraries/process | Version: 7.9
Resolution: | Keywords:
Operating System: Linux | Architecture: Unknown/Multiple
Type of failure: Runtime crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
--------------------------------------+------------------------------------
Changes (by jstolarek):
* os: Unknown/Multiple => Linux
Comment:
Replying to [comment:3 nomeata]:
> But the `translate` function is only used on Windows
No:
{{{
translate :: String -> String
#if mingw32_HOST_OS
translate xs = '"' : snd (foldr escape (True,"\"") xs)
where escape '"' (_, str) = (True, '\\' : '"' : str)
escape '\\' (True, str) = (True, '\\' : '\\' : str)
escape '\\' (False, str) = (False, '\\' : str)
escape c (_, str) = (False, c : str)
-- See long comment above for what this function is trying to do.
--
-- The Bool passed back along the string is True iff the
-- rest of the string is a sequence of backslashes followed by
-- a double quote.
#else
translate "" = "''"
translate str
-- goodChar is a pessimistic predicate, such that if an argument is
-- non-empty and only contains goodChars, then there is no need to
-- do any quoting or escaping
| all goodChar str = str
| otherwise = '\'' : foldr escape "'" str
where escape '\'' = showString "'\\''"
escape c = showChar c
goodChar c = isAlphaNum c || c `elem` "-_.,/"
#endif
}}}
> is your bug report about Windows
No, it's about Linux (does Windows even have awk?)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8802#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list