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

dokondr dokondr at gmail.com
Thu Dec 1 20:47:19 CET 2011


To be precise, $0 always contains the path to the program called. You are
right, this path will change depending on location from which the program
was called. So $0 is OK for my case, while current directory  is unrelated.

Try this:

#!/bin/sh

echo "Arg 0: $0"
echo "All Parameters:  [$@]"

Again, any way to get the same functionality in GHC?


On Thu, Dec 1, 2011 at 10:32 PM, Giovanni Tirloni <gtirloni at sysdroid.com>wrote:

> On Thu, Dec 1, 2011 at 5:26 PM, dokondr <dokondr at gmail.com> wrote:
>
>> 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.
>>
>>
> Are you sure?
>
> $ zero.sh
> ./zero.sh
>
> $ ./zero.sh
> ./zero.sh
>
> $ /home/gtirloni/zero.sh
> /home/gtirloni/zero.sh
>
>
>
> --
> Giovanni
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111201/7ee71930/attachment.htm>


More information about the Haskell-Cafe mailing list