On 04/06/2019 15:52, Joerg Schilling wrote:
Harald van Dijk <[email protected]> wrote:
Currently, two incompatible behaviours are implemented in shells:
(1) Let the result depend on readdir().
(2) Always omit "." and "..".
With the "globskipdot" option, shells that currently implement (1) are
forced to choose. Whatever they choose, they will change behaviour for
some users. They are given two options for the new default behaviour:
The problem with the current situation and with the proposal from bug #1228
is that there is neither a usable state, that a script can rely on, with the
current nor with the proposed state.
And even if the proposed change for bug #1228 would require a shell to hide "."
and "..", the problem would be that script writers cannot know whether the
shell is on a platform that implements issue 7 and earlier or whether it
implements issue 8 and later.
The new proposed set(1) option on the other side allows a script writer to
check which behavior is to be expected from the shell.
It does more than required to achieve that. Adding a set option could be
as simple as
set -o globskipdot
Skip the directory entries for dot and dot-dot if they are encountered
when reading a directory during pathname expansion operations. It is
unspecified whether the default for this option is off (unset) or on
(set). If globskipdot is off, it is unspecified whether (possibly
synthesized) entries for dot or dot-dot are returned.
This would allow shells to always skip "." and ".." and implement set -o
globskipdot as (mostly) a no-op, it would allow shells to preserve the
current behaviour in set +o globskipdot mode where results depend on the
file system, or it would allow shells to implement those new synthesised
"." and ".." entries if any implementers feel that it is a good idea.
I agree with Stephane's reply, I do not expect scripts to set this
option and also handle the possibility that shells do not support it.
However, what I can sort of imagine script authors would do is just set
-o globskipdot at the start of the script to intentionally abort
execution of the script on a shell that does not support it.
Cheers,
Harald van Dijk