Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
Maybe. Then again, it's all about expectations. If things behave as one would expect, there is no learning curve.
That is true, and I didn't expect the current behavior. I thought, if an ls lists it, then it exists. Martin B?hrs expectation expresses the same thing another way: If it doesn't exist then using open() on it in "wcx" mode shouldn't fail. This is the most generic form of existence, and thus imho appropriate for a function called "exist".
True. But given a UNIX/POSIX background, the meaning of "exist" is slightly different and matches exactly with current behaviour.
When it comes to POSIX, does it clearly define such a generic "existence" concept? Just because some functions, e.g. open(2), returns ENOENT in some situations doesn't really account for anything
- there are others, e.g. lstat(2), that do it differently.
Don't ask me to quote standards, since I rarely read up on the POSIX standard itself, all I know is from perusing the programmers manuals and the various POSIX hints in there. However, the concept that POSIX breaths is that the standard "exist" and also the acces(2)/open(2) functions operate on real objects (i.e. files, sockets, directories, devices); whereas symlinks are considered mere pointers, not real objects. These pointers are invisible for most file operations, and need special function-calls to actually handle them (like lstat() vs. stat()).
So in light of the POSIX philosophy, the current Stdio.exist behaviour is perfectly fine, and using an extra flag to make it aware of symlinks would be the proper way to go.