Repository : ssh://darcs.haskell.org//srv/darcs/packages/process

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/5f8452886cc3390123cb879dd4f469150095a343

>---------------------------------------------------------------

commit 5f8452886cc3390123cb879dd4f469150095a343
Author: Ian Lynagh <[email protected]>
Date:   Sat Jul 28 14:39:54 2012 +0100

    Improve showCommandForUser on non-Windows
    
    We no longer gratuitously use '' when they clearly aren't necessary

>---------------------------------------------------------------

 System/Process/Internals.hs |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/System/Process/Internals.hs b/System/Process/Internals.hs
index a73c6fc..4f9159f 100644
--- a/System/Process/Internals.hs
+++ b/System/Process/Internals.hs
@@ -46,6 +46,7 @@ module System.Process.Internals (
 
 #ifndef __HUGS__
 #if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
+import Data.Char
 import System.Posix.Types
 import System.Posix.Process.Internals ( pPrPr_disableITimers, c_execvpe )
 import System.IO        ( IOMode(..) )
@@ -588,9 +589,16 @@ translate str = '"' : snd (foldr escape (True,"\"") str)
         -- rest of the string is a sequence of backslashes followed by
         -- a double quote.
 #else
-translate str = '\'' : foldr escape "'" str
+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 == '-' || c == '_'
 #endif
 
 -- ----------------------------------------------------------------------------



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to