projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0e5f019
)
Fix "runghc foo" where the program is foo.hs or foo.lhs
author
Ian Lynagh
<igloo@earth.li>
Mon, 25 Aug 2008 19:43:52 +0000
(19:43 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Mon, 25 Aug 2008 19:43:52 +0000
(19:43 +0000)
utils/runghc/runghc.hs
patch
|
blob
|
history
diff --git
a/utils/runghc/runghc.hs
b/utils/runghc/runghc.hs
index
decbdcd
..
1ce358e
100644
(file)
--- a/
utils/runghc/runghc.hs
+++ b/
utils/runghc/runghc.hs
@@
-82,9
+82,16
@@
doIt ghc args = do
hClose h
doIt ghc (ghc_args ++ [filename])
filename : prog_args -> do
hClose h
doIt ghc (ghc_args ++ [filename])
filename : prog_args -> do
- let xflag = if takeExtension filename == ".lhs"
- then []
- else ["-x", "hs"]
+ -- If the file exists, and is not a .lhs file, then we
+ -- want to treat it as a .hs file.
+ --
+ -- If the file doesn't exist then GHC is going to look for
+ -- filename.hs and filename.lhs, and use the appropriate
+ -- type.
+ exists <- doesFileExist filename
+ let xflag = if exists && (takeExtension filename /= ".lhs")
+ then ["-x", "hs"]
+ else []
c1 = ":set prog " ++ show filename
c2 = ":main " ++ show prog_args
res <- rawSystem ghc (["-ignore-dot-ghci"] ++
c1 = ":set prog " ++ show filename
c2 = ":main " ++ show prog_args
res <- rawSystem ghc (["-ignore-dot-ghci"] ++