[Haskell-cafe] How to get a file path to the program invoked?

Simon Hengel simon.hengel at wiktory.org
Thu Dec 1 19:02:09 CET 2011


On Thu, Dec 01, 2011 at 03:53:37PM -0200, Felipe Almeida Lessa wrote:
> On Thu, Dec 1, 2011 at 3:41 PM, Simon Hengel <simon.hengel at wiktory.org> wrote:
> >> > How to get this path in Haskell?
> >>
> >> If I understand you correctly, you want
> >>
> >>   takeDirectory `fmap` getProgName
> >
> > I think getProgName does not give you the full path, but only the
> > program name.
> 
> Neither does $0, does it?  It depends on how the program is called.
$0 depend everything you need to find your program (say, the relative or
absolute path used), but getProgName does not.  Here is an example:

    ./foo/foo

Here $0 will be "./foo/foo", but getProgName will be "foo".

Cheers,
Simon



More information about the Haskell-Cafe mailing list