On Tue, May 16, 2017 at 2:48 AM, Zoltán Herczeg <hzmes...@freemail.hu> wrote: > Hi, > > bash enter an infinite loop for this glob: > > ls @(@()).
It works fine for me. What version of Bash are you using? And, what files are in the directory you're testing in? dualbus@debian:~/t$ ls a.1 a.2 a.3 a.4 b.1 b.2 b.3 b.4 c.1 c.2 c.3 c.4 d.1 d.2 d.3 d.4 dualbus@debian:~/t$ ls @(@()). a.1 a.2 a.3 a.4 b.1 b.2 b.3 b.4 c.1 c.2 c.3 c.4 d.1 d.2 d.3 d.4 dualbus@debian:~/t$ GNU bash, version 4.4.11(1)-release (x86_64-pc-linux-gnu) > I have been trying to create a bash glob regex converter. It would be great > if somebody (privately) could explain me how !() and invalid [] expressions > exactly work. I have questions such as: > > ls a[[:alpha:][:abm] > > Why does this match to a: and nothing else (e.g. am or a[mm )? The shell globbing library seems to be interpreting this pattern weirdly. I don't know the answer for this, but the glob() call in glibc does what I expect: dualbus@debian:~/t$ ls a: aa ab dualbus@debian:~/t$ ls a[[:alpha:][:abm] a: dualbus@debian:~/t$ ../glob a: aa ab dualbus@debian:~/t$ cat ../glob.c #include <stdlib.h> #include <stdio.h> #include <glob.h> int main() { int i; glob_t pglob; if(glob("a[[:alpha:][:abm]", 0, NULL, &pglob)) perror(NULL); for(i = 0; i < pglob.gl_pathc; i++) { puts(pglob.gl_pathv[i]); } return 0; }