summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2013-10-06 23:38:34 +0200
committerJoachim Breitner <mail@joachim-breitner.de>2013-10-09 10:02:26 +0200
commitddc79b229d58c1bed8ae19b955b491436e015e96 (patch)
treece92068a424755fbdd55aac7f2b70eb35cbc8638
parent2a182ab89532596fdcfaedcafca1bfd3ba8d2b8e (diff)
downloadhaskell-ddc79b229d58c1bed8ae19b955b491436e015e96.tar.gz
GHCi: Expand ~ in :script command
Fixes: #7685
-rw-r--r--ghc/InteractiveUI.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 389b99e0d1..eb32aa6e0c 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