Stephane CHAZELAS <[email protected]> wrote:

> Why make it default off? The sane value (where "chmod 644 .*"
> or "rm -rf .*/snapshot" work as people would expect for
> instance) would be on.

> The only reason why I can imagine you'd want to default to off
> would be if you want to keep some level of backward
> compatibility.

OK, my reasoning for keeping it off by default was to ensure backwards 
compatibility to the historical behavior that is currently mandated by POSIX.

But you finally conviced me to use "set -o globskipdot" as the new default.

> But here, that's not even the case as you're synthesizing "." and
> ".." when it's off which is a change of behaviour from the old
> behaviour.

The reason for synthesizing the entries is backwards compatibility to historic 
filesystems and to permit people that expect the historic behavior from the 
1970s to be used in their code.

When I wrote WOFS in 1990 (the first filesystem that does not have . and ..), 
I discovered that some badly written programs had problems with the behavior 
of WOFS, but today I no longer remember whether this was also caused by missing 
. and .. or rather only by the fact that a directory on WOFS is a zero sized
"directory special" file with a link count of 1 (unless there exist explicit
hard links). Please remember that in 1990 there have been many programs that 
did use scandir() and that function allocated an array with a size based on the 
value of stat.st_size of the directory using a formular that was only correct 
for the UFS filesystem type.

On the other side, the POSIX standard from 1992 makes it obvious that the 
presence of . and .. is not what people should rely on. Unfortunately, POSIX 
did not use the past time to implement a soft change towards a less risky 
mandated behavior for . and .. and we thus lost some time we could have already 
used for a transition.


> The only remotely plausible reason I can think of why anyone
> would want globs to include "." and ".." would be people trying
> to find out whether readdir() returns them.
>
> Like:
>
> if [ .[.] = '.[.]' ]; then
>   echo "Not a UNIX file system"
> fi
>
> Which would have worked on some systems with some shells
> (including bosh before the change).

This is true, but do you have any benefit from knowing whether a filesystem 
returns . and .. via readdir()?

Finally, you convinced me to make "set -o globskipdot" the default, 
configurable 
via: #define DO_GLOBSKIPDOT_DEF.

I even configured this new default in the Makefile - in hope that people 
understand that POSIX is going to permit this new behavior soon....

For those who still believe, that "set -o globskipdot" is not needed in a 
shell, please note that this can be seen as a marker that allows to use the new 
behavior immediately instead of waiting until at least y2040 until all relevant 
shells did probably make the transition.

Jörg

-- 
 EMail:[email protected]                    (home) Jörg Schilling D-13353 Berlin
    [email protected] (work) Blog: http://schily.blogspot.com/
 URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'

Reply via email to