Discussion:
Nested extglob outputs "." ".."
Michal Pesa
2018-08-22 07:57:19 UTC
Permalink
Hello, I have encountered a strange behavior of nested extended globs:

$ echo *
0000.txt 000.txt 00.txt 0.txt a.txt b.txt c.txt
$ echo !(0.txt)
0000.txt 000.txt 00.txt a.txt b.txt c.txt
$ echo !(+(0).txt)
. .. a.txt b.txt c.txt

The last example correctly excludes the files but why are "." ".." being
printed?

Thank you for your time.

Configuration Information:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_$
uname output: Linux pish-lub 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17
15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 19
Release Status: release
Greg Wooledge
2018-08-22 12:31:16 UTC
Permalink
Post by Michal Pesa
$ echo *
0000.txt 000.txt 00.txt 0.txt a.txt b.txt c.txt
$ echo !(0.txt)
0000.txt 000.txt 00.txt a.txt b.txt c.txt
$ echo !(+(0).txt)
. .. a.txt b.txt c.txt
The last example correctly excludes the files but why are "." ".." being
printed?
This appears to be fixed already in bash 5.0-alpha.
Chet Ramey
2018-08-22 13:16:12 UTC
Permalink
Post by Michal Pesa
$ echo *
0000.txt 000.txt 00.txt 0.txt a.txt b.txt c.txt
$ echo !(0.txt)
0000.txt 000.txt 00.txt a.txt b.txt c.txt
$ echo !(+(0).txt)
. .. a.txt b.txt c.txt
The last example correctly excludes the files but why are "." ".." being
printed?
This was changed back in January as the result of a discussion started by

http://lists.gnu.org/archive/html/bug-bash/2017-12/msg00074.html

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Michal Pesa
2018-08-22 19:19:30 UTC
Permalink
My bad, sorry for not searching properly before asking. Thank you for
your time.
Post by Chet Ramey
Post by Michal Pesa
$ echo *
0000.txt 000.txt 00.txt 0.txt a.txt b.txt c.txt
$ echo !(0.txt)
0000.txt 000.txt 00.txt a.txt b.txt c.txt
$ echo !(+(0).txt)
. .. a.txt b.txt c.txt
The last example correctly excludes the files but why are "." ".." being
printed?
This was changed back in January as the result of a discussion started by
http://lists.gnu.org/archive/html/bug-bash/2017-12/msg00074.html
Chet
Chet Ramey
2018-08-22 20:05:17 UTC
Permalink
My bad, sorry for not searching properly before asking. Thank you for your
time.
No problem, you should always report against the latest version you have.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Loading...