System.Directory.getCurrentDirectory does not solve the problem.
System.Directory.getCurrentDirectory returns the directory *from which* the program was called, also called "working directory".
The directory *from which* the program was called is not the same that the directory *where the program executable is*, which my program needs to know.
For example:
/opt/myApp/test/myProg - is a program
One may call it in many ways:
1)
cd /opt/myApp/test/
./myProg
Current or working directory: ./
or:
2)
cd /usr/local
/opt/myApp/test/myProg
Current or working directory: /usr/local
On the contrary, standard shell variable $0 - contains a full path to the program location in the directory structure, no matter from what directory the program was called.
How to find this path using GHC libraries?
Neither does $0, does it? It depends on how the program is called.
You can always use System.Directory.getCurrentDirectory with
System.FilePath.{isRelative,replaceDirectory} if you somehow need the
full path. Note, however, that not even this is generally guaranteed
to be correct.
Cheers,
--
Felipe.