On Fri, Nov 11, 2011 at 7:59 PM, Evan Laforge <qdunkan@gmail.com> wrote:
> System.Environment exports:
>
> getProgName :: IO String
>
> maybe System.Posix.ByteString should export a similar function:
>
> getProgName :: IO ByteString

Yeah, that's actually not the same as argv[0], it has the path to the
binary stripped.  So you can't really use it to restart yourself
because you have no way to know what directory the binary was in.
It's frustrating because you can see in the source that it's going to
some effort to intentionally strip off information that you can't get
elsewhere.


FYI, there are at least two libraries out there trying to solve this problem:

http://hackage.haskell.org/package/executable-path
http://hackage.haskell.org/package/FindBin

Unfortunately, there is no standardized way on different unix systems
to access the path of the executable running (it's not even fully
clear what it means in the presence of symlinks, etc). Actually it seems
to be impossible to do this (without argv[0]) on certain BSD systems.

Balazs