[commit: ghc] master: GHCi: Expand ~ in :script command (ddc79b2)

git at git.haskell.org git
Wed Oct 9 08:35:50 UTC 2013


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ddc79b229d58c1bed8ae19b955b491436e015e96/ghc

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

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

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


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

ddc79b229d58c1bed8ae19b955b491436e015e96
 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