Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
c38ec601
Commit
c38ec601
authored
Jan 20, 2008
by
Ian Lynagh
Browse files
Tweak runghc
parent
0ebfc8bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils/runghc/runghc.hs
View file @
c38ec601
...
...
@@ -61,31 +61,23 @@ doIt ghc args = do
case
rest
of
[]
->
dieProg
usage
filename
:
prog_args
->
do
let
expr
=
"System.Environment.withProgName "
++
show
filename
++
" (System.Environment.withArgs "
++
show
prog_args
++
" (GHC.TopHandler.runIOFastExit"
++
" (Main.main Prelude.>> Prelude.return ())))"
let
c1
=
":set prog "
++
show
filename
c2
=
":main "
++
show
prog_args
res
<-
rawSystem
ghc
([
"-ignore-dot-ghci"
]
++
ghc_args
++
[
"-e"
,
expr
,
filename
])
-- runIOFastExit: makes exceptions raised by Main.main
-- behave in the same way as for a compiled program.
-- The "fast exit" part just calls exit() directly
-- instead of doing an orderly runtime shutdown,
-- otherwise the main GHCi thread will complain about
-- being interrupted.
--
-- Why (main >> return ()) rather than just main? Because
-- otherwise GHCi by default tries to evaluate the result
-- of the IO in order to show it (see #1200).
[
"-e"
,
c1
,
"-e"
,
c2
,
filename
])
exitWith
res
getGhcArgs
::
[
String
]
->
([
String
],
[
String
])
getGhcArgs
args
=
case
break
pastArgs
args
of
(
xs
,
"--"
:
ys
)
->
(
xs
,
ys
)
(
xs
,
ys
)
->
(
xs
,
ys
)
getGhcArgs
args
=
let
(
ghcArgs
,
otherArgs
)
=
case
break
pastArgs
args
of
(
xs
,
"--"
:
ys
)
->
(
xs
,
ys
)
(
xs
,
ys
)
->
(
xs
,
ys
)
in
(
map
unescape
ghcArgs
,
otherArgs
)
where
unescape
(
'-'
:
'-'
:
'g'
:
'h'
:
'c'
:
'-'
:
'a'
:
'r'
:
'g'
:
'='
:
arg
)
=
arg
unescape
arg
=
arg
pastArgs
::
String
->
Bool
-- You can use -- to mark the end of the flags, in ca
e
s you need to use
-- You can use -- to mark the end of the flags, in cas
e
you need to use
-- a file called -foo.hs for some reason. You almost certainly shouldn't,
-- though.
pastArgs
"--"
=
True
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment