Mike Meyer <[EMAIL PROTECTED]> writes: > In <[EMAIL PROTECTED]>, Dag-Erling Smørgrav <[EMAIL PROTECTED]> typed: > > You got it the wrong way around. First pass argv[0] to realpath(3), > > fall back to using $PATH only if realpath(3) fails (which it shouldn't > > unless you've called chdir(2), chroot(2) or jail(2) earlier in the > > process, or the executable was moved or removed) > No, I got it the right way 'round. If the shell walks the PATH, then > calling realpath(3) on argv[0] is the wrong thing to do, as it'll > resolve the path relative to the pwd.
but argv[0] is either an absolute path or a path relative to pwd, unless your shell is broken. [EMAIL PROTECTED] ~% cat >bin/foo #!/bin/sh echo $0 $@ [EMAIL PROTECTED] ~% chmod a+rx bin/foo [EMAIL PROTECTED] ~% ./bin/foo ./bin/foo [EMAIL PROTECTED] ~% foo /home/des/bin/foo DES -- Dag-Erling Smørgrav - [EMAIL PROTECTED] _______________________________________________ [email protected] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"

