On Saturday 16 April 2005 01:53, Michael G Schwern wrote: > How cwd() is implemented is not so important as what happens when it hits > an edge case. So maybe we can try to come up with a best fit cwd(). I'd > start by listing out the edge cases and what the possible behaviors are. > Maybe we can choose a set of behaviors which is most sensible across all > scenarios and define cwd() to act that way. Or maybe even just define what > various cwd variations currently do. > > Here's the ones I know of off the top of my head. You probably know more. > > * The cwd is deleted > * A parent directory is renamed > * A parent directory is a symlink
There is also the possibility for permissions issues: * You don't have permissions to determine cwd as an absolute pathname * You are in a directory that you couldn't have chdir'ed into (that makes the localized $CWD fail to return you to the original location when it goes out of scope). It's not hard to run a program that is setuid (to a non-root account) from within a directory that is owner-only accessible.