On 2019/06/04 06:12, Andreas Grapentin wrote:
> I would personally offer the opinion that any `sane' or `expected'
> behavior must depend on the use case. Situations can be constructed
> where each of the two possible behaviours can be desirable:
>
>   # should probably not include ../
>   $ rm -r .*/
>
>   # should probably include ../
>   $ grep '#include' .*/*.{c,h}
>   
----
    Like Stephane, I can't see subbing in a '.'(or a '..') for either
position
of '*' in that statement.  Certainly,
  "grep '#include' ../*.{c,h}" makes no sense for something globbing would
insert. 
    At the same time, I can't see any reason why globbing would insert
'..' (or '.') for the second '*' by default:
neither .*/...{c,h}  nor
        .*/.*.{c,h} make sense to assume by default.

Though, if you are saying that the user probably wants
        ".*/*.{c,h}" to include
        "./*.{c,h}", along with any "hidden directories" in the
current directory, then I'd agree (and obviously, not any hidden files in
the current or hidden directories).

I would think the default is for the shell to never expand '*' to
a '.' as the first character in a match.

If the user turned on some option 'glob-include-hidden', then

'*' would match 1 or more dots at the beginning of a filename but only if
there was a non-dot after the dot(s) the shell returned.

By that rule, '*' would never return '.', as a single char.
It could return '.[^.]' (.like .apple) and it could return '..[^.]'
(..like ..apple).  However those items would only be return if a special
glob switch (to match hidden files) was turned on.  If it is not turned on,
then '*' would never return a word starting with a '.'

Rephrasing as simple statements, say "dotglob" was a switch that when
enabled, would allow globbing to return "hidden" files (ones that start
with 1 or more dots and also include a character matching '[^.]' after
the initial dot (or
dots).

  Then:

1) With that switch off, globbing would never return a match on a string
starting with a dot.

2) with that switch on, globbing would only return a match on a file with
1 or more dots at the beginning that was prepended to a character matching
[^.].


Does that seem reasonable & logical?

Reply via email to