Inside PWD

Doug Gwyn gwyn at smoke.BRL.MIL
Mon Oct 16 16:43:18 AEST 1989


In article <1281 at virtech.UUCP> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>BTW - there is no system call to do this because the system doesn't know
>where you are (other than the inode of your current directory).

More accurately, the inode defines WHERE you are, but not how you got there.
Note that the usual getcwd() methods return A path from the root, not THE
path you used.  Some shells (e.g. the one I maintain) keep track of how you
reach your c.w.d., and some (e.g. ksh) even keep track of it in a variable.
If the c.w.d. could reliably be trusted to be in an environment variable,
then an alternate, and generally less confusing, implementation of getcwd()
suggests itself.  However, it wouldn't be reliable from a security standpoint.



More information about the Comp.unix.wizards mailing list