I expected that
compgen -A file -G './tmp/*.sh'
would show only files under tmp/, but it also showed all files in the current directory.
I have tried
compgen -A file -X '!(tmp/*.sh)'
and
compgen -A file -X "!(tmp/*.sh)"
but both result in null output. Checking settings:
$ shopt|grep extglob
extglob on
It's also worth noting that
compgen -A file tmp/*.sh
returns only the first valid candidate. Incidentally, this exactly matches the default line completion result, e.g.
cp tmp/*.sh[TAB]
and
ls tmp/*.sh[TAB]
both expand out to only the first candidate.
Two questions:
- Why?
- Any way to get the expected result using only
compgen?
The 'expected result' is for all the matching candidates to be returned, as would happen with ls tmp/*.sh