Plugins: How to determine ghc vs ghci

Michael Sloan mgsloan at gmail.com
Wed Nov 25 02:25:58 UTC 2015


The executable-path package wraps this up nicely with its `getScriptPath`
function:

https://hackage.haskell.org/package/executable-path-0.0.3/docs/System-Environment-Executable.html#v:getScriptPath

Probably best to use this existing function.  Then, if a less fragile
solution comes along, getScriptPath can do that instead.

-Michael

On Tue, Nov 24, 2015 at 5:58 PM, Levent Erkok <erkokl at gmail.com> wrote:

> Thanks! That indeed does work.
>
> I'm a bit surprised though that there isn't already an internal boolean
> set somewhere; checking for a string in the arguments sounds a bit fragile.
>
> On Tue, Nov 24, 2015 at 12:28 AM, Aycan İrican <iricanaycan at gmail.com>
> wrote:
>
>> How about `GHC.Environment.getFullArgs` which includes “—interactive”
>> when you’re in GHCi?
>>
>>
>> > On 24 Nov 2015, at 09:37, Levent Erkok <erkokl at gmail.com> wrote:
>> >
>> > I'm working on a plugin, and would like to be able to tell if it's GHC
>> or GHCi that's running.
>> >
>> > I tried:
>> >
>> >    df   <- getDynFlags
>> >    let isGHCi = ghcMode df == CompManager
>> >
>> > Alas, while that correctly tells apart "ghci" from "ghc -c", it also
>> returns True when ghc is called without the "-c" argument.
>> >
>> > Is there a better/more robust way of figuring out whether we're in an
>> interactive session?
>> >
>> > -Levent.
>> > _______________________________________________
>> > ghc-devs mailing list
>> > ghc-devs at haskell.org
>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>>
>>
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20151124/fec09a93/attachment.html>


More information about the ghc-devs mailing list