<div dir="ltr">The executable-path package wraps this up nicely with its `getScriptPath` function:<div><br></div><div><a href="https://hackage.haskell.org/package/executable-path-0.0.3/docs/System-Environment-Executable.html#v:getScriptPath">https://hackage.haskell.org/package/executable-path-0.0.3/docs/System-Environment-Executable.html#v:getScriptPath</a><br></div><div><br></div><div>Probably best to use this existing function.  Then, if a less fragile solution comes along, getScriptPath can do that instead.<br></div><div><br></div><div>-Michael</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 24, 2015 at 5:58 PM, Levent Erkok <span dir="ltr"><<a href="mailto:erkokl@gmail.com" target="_blank">erkokl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks! That indeed does work.<div><br></div><div>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.<span class=""><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 24, 2015 at 12:28 AM, Aycan İrican <span dir="ltr"><<a href="mailto:iricanaycan@gmail.com" target="_blank">iricanaycan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">How about `GHC.Environment.getFullArgs` which includes “—interactive” when you’re in GHCi?<br>
<div><div><br>
<br>
> On 24 Nov 2015, at 09:37, Levent Erkok <<a href="mailto:erkokl@gmail.com" target="_blank">erkokl@gmail.com</a>> wrote:<br>
><br>
> I'm working on a plugin, and would like to be able to tell if it's GHC or GHCi that's running.<br>
><br>
> I tried:<br>
><br>
>    df   <- getDynFlags<br>
>    let isGHCi = ghcMode df == CompManager<br>
><br>
> Alas, while that correctly tells apart "ghci" from "ghc -c", it also returns True when ghc is called without the "-c" argument.<br>
><br>
> Is there a better/more robust way of figuring out whether we're in an interactive session?<br>
><br>
> -Levent.<br>
</div></div>> _______________________________________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
<br>
</blockquote></div><br></div></span></div></div>
<br>_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
<br></blockquote></div><br></div>