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@gmail.com> wrote:
Christian Maeder wrote:
Alfonso Acosta wrote:
On Nov 19, 2007 10:51 AM, Alfonso Acosta <alfonso.acosta@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