[Haskell-cafe] How to get a file path to the program invoked?
wren ng thornton
wren at freegeek.org
Sun Dec 4 07:23:57 CET 2011
On 12/1/11 11:12 AM, dokondr wrote:
> Hi,
> When my program starts it needs to know a complete path to the directory
> from which it was invoked.
> In terms of standard shell (sh) I need the Haskell function that will do
> equivalent to:
>
> #!/bin/sh
> path=$(dirname $0)
That's not the path to the directory from which the script is invoked
(aka, $PWD or, more accurately, the results of `pwd`). That's the path
to the directory containing the script.
The current working directory (the dir from which the program is
invoked, provided the program haven't moved since invocation) can be
gotten by System.Directory.getCurrentDirectory in the directory package.
Getting the path to the location of the executable is trickier business.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list