It's not a poor practice at all. Example: gcc, which uses the executable's path as the base directory from which other files are located. MacOS also does something similar.

-----Original message-----
From: Paul R <paul.r...@gmail.com>
To: dokondr <doko...@gmail.com>
Cc: Simon Hengel <simon.hen...@wiktory.org>, haskell-cafe <haskell-cafe@haskell.org>
Sent: Sun, Dec 4, 2011 15:26:28 PST
Subject: Re: [Haskell-cafe] How to get a file path to the program invoked?

dokondr> On the contrary, standard shell variable $0 - contains a full
dokondr> path to the program location in the directory structure, no
dokondr> matter from what directory the program was called.

I don't think the comparison makes sense, as shell script invocation and
executable run are very different mechanisms. Whenever you invoke
a shell script, what really happens is that a program in your path (sh,
bash ...) gets started with an argument that is the path to the script
to load (your script actually). In this situation, you understand that
it is easy to provide the path to the script (the $0) : it is just the
file that the interpreter is loading.

I don't know if it is possible at all to get this information in the
context of binary execution. And I'm not sure it is a good practice
anyway :)

--
 Paul

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to