[commit: ghc] wip/T7685: GHCi: Expand ~ in :script command (181975b)

git at git.haskell.org git
Sun Oct 6 21:39:35 UTC 2013


Repository : ssh://git at git.haskell.org/ghc

On branch  : wip/T7685
Link       : http://ghc.haskell.org/trac/ghc/changeset/181975b01c1c84f22700e0e1ee64b9124b60cc08/ghc

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

commit 181975b01c1c84f22700e0e1ee64b9124b60cc08
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Sun Oct 6 23:38:34 2013 +0200

    GHCi: Expand ~ in :script command
    
    Fixes: #7685


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

181975b01c1c84f22700e0e1ee64b9124b60cc08
 ghc/InteractiveUI.hs |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 389b99e..eb32aa6 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -1146,7 +1146,7 @@ trySuccess act =
 
 editFile :: String -> InputT GHCi ()
 editFile str =
-  do file <- if null str then lift chooseEditFile else return str
+  do file <- if null str then lift chooseEditFile else expandPath str
      st <- lift getGHCiState
      let cmd = editor st
      when (null cmd)
@@ -1495,7 +1495,8 @@ scriptCmd ws = do
 runScript :: String    -- ^ filename
            -> InputT GHCi ()
 runScript filename = do
-  either_script <- liftIO $ tryIO (openFile filename ReadMode)
+  filename' <- expandPath filename
+  either_script <- liftIO $ tryIO (openFile filename' ReadMode)
   case either_script of
     Left _err    -> throwGhcException (CmdLineError $ "IO error:  \""++filename++"\" "
                       ++(ioeGetErrorString _err))
@@ -1503,7 +1504,7 @@ runScript filename = do
       st <- lift $ getGHCiState
       let prog = progname st
           line = line_number st
-      lift $ setGHCiState st{progname=filename,line_number=0}
+      lift $ setGHCiState st{progname=filename',line_number=0}
       scriptLoop script
       liftIO $ hClose script
       new_st <- lift $ getGHCiState




More information about the ghc-commits mailing list