GHC 6.8.1 on Mac OS X 10.5 (Leopard)

Christian Maeder Christian.Maeder at dfki.de
Mon Nov 19 07:07:51 EST 2007


An additional sanity check of "topdir" makes sense then.

Christian

Alfonso Acosta wrote:
> Simon, as usual, is right. It's been quite a while since I last
> seriously coded in C. From the exec* man page:
> 
> "The first argument, *by convention*, should point to the file name
> associated with the file being executed."
> 
> However, if nothing better is found I guess it's better to rely on an
> extended convention rather than hardcoding paths.
> 
> On Nov 19, 2007 11:40 AM, Simon Marlow <simonmarhaskell at gmail.com> wrote:
>> Christian Maeder wrote:
>>> Alfonso Acosta wrote:
>>>> On Nov 19, 2007 10:51 AM, Alfonso Acosta <alfonso.acosta at gmail.com> wrote:
>>>>> Well, you can always combine the first argument of the script ($0) for
>>>>> absolute paths and combine it with with pwd for relative ones.
>>>> I meant _use_ the first argument of the script ($0) for absolute paths
>>>> and combine it with pwd for relative ones.
>>> #!/bin/sh
>>> reldir=`dirname $0`
>>> topdir=`(cd $reldir; pwd)`
>> There's no guarantee that $0 holds anything reasonable: you can set $0 to
>> whatever you like when calling exec*().
>>
>> Cheers,
>>         Simon
>>


More information about the Glasgow-haskell-users mailing list