On 12/30/2012 05:16:41 AM, Felix Janda wrote:
On 12/30/12 at 04:43am, Rob Landley wrote:
POSIX contains many surprises. In the section on environment variables it says that $PWD should be set if "pwd -P" was specified. What happens if an
error happens seems unspecified.

Translation: pwd must be a shell builtin running within the shell's process ID, and cannot sanely be implemented any other way.

It would be nice if they would just _identify_ these. I did a pass to find them (in the roadmap), but missed this.

> Sigh. And the whole "PWD defaults to -P unless POSIXLY_CORRECT" thing
> above: while I'm sure that code is in there, it's not actually what
> it's doing here. Because GNU code is INSANE, and someone somewhere
> thought this tangle of corner cases might help somehow.
>
> Right, in the case of a deleted directory $PWD is all we've got, so
> have -L (which is the default) print it but first validate it's an
> absolute path with no .. in it. Only validate that current directory
> and path directory point to the same place if there IS a current
> directory. If that's not what they want, -P exists.

In the corner case shouldn't pwd (-L and -P) just give an error message?
($PWD does not contain an absolute pathname of the current working
directory.)

If something deletes the directory you're working in, "cd .." should work if the directory above you exists. That can't happen if $PWD isn't there.

Also, when a directory gets deleted and recreated I do cd "$(pwd)" all the time. It's useful to still have pwd if some other process takes out the directory you're in.

Rob
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to