From d061166982c65f8e61b4faf942bc5737da2b272c Mon Sep 17 00:00:00 2001
From: "cdsmith@twu.net" <unknown>
Date: Fri, 1 Jun 2007 05:36:44 +0000
Subject: [PATCH] FIX #1378 Add option for a shorter banner on GHCi startup

Add -short-ghci-banner and -long-ghci-banner.  The default is long, which is
the current behavior.  The short banner prints a one-line introduction with
only the version, web site, and ":? for help" message.
---
 compiler/ghci/InteractiveUI.hs |  7 ++++++-
 compiler/main/Main.hs          |  8 +++++---
 compiler/main/StaticFlags.hs   |  4 ++++
 docs/users_guide/flags.xml     | 12 ++++++++++++
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs
index 02344cf561fd..2497bada366f 100644
--- a/compiler/ghci/InteractiveUI.hs
+++ b/compiler/ghci/InteractiveUI.hs
@@ -8,7 +8,8 @@
 -----------------------------------------------------------------------------
 module InteractiveUI ( 
 	interactiveUI,
-	ghciWelcomeMsg
+	ghciWelcomeMsg,
+	ghciShortWelcomeMsg
    ) where
 
 #include "HsVersions.h"
@@ -90,6 +91,10 @@ ghciWelcomeMsg =
  "/ /_\\\\/ __  / /___| |    http://www.haskell.org/ghc/\n"++
  "\\____/\\/ /_/\\____/|_|    Type :? for help.\n"
 
+ghciShortWelcomeMsg =
+    "GHCi, version " ++ cProjectVersion ++
+    ": http://www.haskell.org/ghc/  :? for help"
+
 type Command = (String, String -> GHCi Bool, Bool, String -> IO [String])
 cmdName (n,_,_,_) = n
 
diff --git a/compiler/main/Main.hs b/compiler/main/Main.hs
index d5e8de75c3cb..2b173104fb20 100644
--- a/compiler/main/Main.hs
+++ b/compiler/main/Main.hs
@@ -24,7 +24,7 @@ import HscMain          ( newHscEnv )
 import DriverPipeline	( oneShot, compileFile )
 import DriverMkDepend	( doMkDependHS )
 #ifdef GHCI
-import InteractiveUI	( ghciWelcomeMsg, interactiveUI )
+import InteractiveUI	( ghciWelcomeMsg, ghciShortWelcomeMsg, interactiveUI )
 #endif
 
 -- Various other random stuff that we need
@@ -430,8 +430,10 @@ showBanner cli_mode dflags = do
    let verb = verbosity dflags
 	-- Show the GHCi banner
 #  ifdef GHCI
-   when (isInteractiveMode cli_mode && verb >= 1) $
-      hPutStrLn stdout ghciWelcomeMsg
+   let msg = if opt_ShortGhciBanner
+             then ghciShortWelcomeMsg
+             else ghciWelcomeMsg
+   when (isInteractiveMode cli_mode && verb >= 1) $ hPutStrLn stdout msg
 #  endif
 
 	-- Display details of the configuration in verbose mode
diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs
index 0d17af2dcbed..06a47b5a653c 100644
--- a/compiler/main/StaticFlags.hs
+++ b/compiler/main/StaticFlags.hs
@@ -61,6 +61,7 @@ module StaticFlags (
 
 	-- misc opts
 	opt_IgnoreDotGhci,
+	opt_ShortGhciBanner,
 	opt_ErrorSpans,
 	opt_GranMacros,
 	opt_HiVersion,
@@ -143,6 +144,8 @@ static_flags = [
 	------- GHCi -------------------------------------------------------
      ( "ignore-dot-ghci", PassFlag addOpt )
   ,  ( "read-dot-ghci"  , NoArg (removeOpt "-ignore-dot-ghci") )
+  ,  ( "short-ghci-banner", PassFlag addOpt )
+  ,  ( "long-ghci-banner" , NoArg (removeOpt "-short-ghci-banner") )
 
 	------- ways --------------------------------------------------------
   ,  ( "prof"		, NoArg (addWay WayProf) )
@@ -273,6 +276,7 @@ unpacked_opts =
 
 
 opt_IgnoreDotGhci		= lookUp FSLIT("-ignore-dot-ghci")
+opt_ShortGhciBanner             = lookUp FSLIT("-short-ghci-banner")
 
 -- debugging opts
 opt_PprStyle_Debug		= lookUp  FSLIT("-dppr-debug")
diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
index aca1d4763e91..0ff729b2b6f9 100644
--- a/docs/users_guide/flags.xml
+++ b/docs/users_guide/flags.xml
@@ -481,6 +481,18 @@
 	      <entry>static</entry>
 	      <entry>-</entry>
 	    </row>
+	    <row>
+	      <entry><option>-short-ghci-banner</option></entry>
+	      <entry>Display a one-line banner at GHCi startup</entry>
+	      <entry>static</entry>
+	      <entry>-</entry>
+	    </row>
+	    <row>
+	      <entry><option>-long-ghci-banner</option></entry>
+	      <entry>Display a full banner at GHCi startup</entry>
+	      <entry>static</entry>
+	      <entry>-</entry>
+	    </row>
 	    <row>
 	      <entry><option>-fdebugging</option></entry>
 	      <entry>Generate bytecode enabled for debugging</entry>
-- 
GitLab