From d56abb94b11a2ea2985da2e86ad8aa1796b5969a Mon Sep 17 00:00:00 2001
From: ijones <ijones@syntaxpolice.org>
Date: Tue, 9 Aug 2005 01:25:23 +0000
Subject: [PATCH] cvs commit from ross   installHugs: quote the script name to
 protect spaces, and create .bat   files for executables under Windows.

---
 Distribution/Simple/Install.hs | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/Distribution/Simple/Install.hs b/Distribution/Simple/Install.hs
index ac1849f9fd..4b47ab169e 100644
--- a/Distribution/Simple/Install.hs
+++ b/Distribution/Simple/Install.hs
@@ -185,19 +185,23 @@ installHugs verbose libPref binPref targetLibPref buildPref pkg_descr = do
         try $ removeDirectoryRecursive installDir
         smartCopySources verbose [buildDir] installDir
             ("Main" : otherModules (buildInfo exe)) hugsInstallSuffixes True
-#if !(mingw32_HOST_OS || mingw32_TARGET_OS)
-        -- FIX (HUGS): works for Unix only
-        let targetName = targetDir `joinFileName` hugsMainFilename exe
-        let exeFile = binPref `joinFileName` exeName exe
+        let targetName = "\"" ++ (targetDir `joinFileName` hugsMainFilename exe) ++ "\""
         -- FIX (HUGS): use extensions, and options from file too?
         let hugsOptions = hcOptions Hugs (options (buildInfo exe))
+#if mingw32_HOST_OS || mingw32_TARGET_OS
+        let exeFile = binPref `joinFileName` exeName exe `joinFileExt` "bat"
         let script = unlines [
-                "#! /bin/sh", 
+                "@echo off",
+                unwords ("runhugs" : hugsOptions ++ [targetName, "%*"])]
+#else
+        let exeFile = binPref `joinFileName` exeName exe
+        let script = unlines [
+                "#! /bin/sh",
                 unwords ("runhugs" : hugsOptions ++ [targetName, "\"$@\""])]
+#endif
         writeFile exeFile script
         perms <- getPermissions exeFile
         setPermissions exeFile perms { executable = True, readable = True }
-#endif
 
 hugsInstallSuffixes :: [String]
 hugsInstallSuffixes = ["hs", "lhs", dllExtension]
-- 
GitLab