`compgen -A file -G './tmp/*.sh` unexpectedly shows ALL the files in directory ./ as well as the desired ones
0
votes
1
answer
307
views
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:
1. Why?
2. 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
Asked by Craig Hicks
(746 rep)
Jun 25, 2020, 05:17 PM
Last activity: Jun 25, 2020, 06:49 PM
Last activity: Jun 25, 2020, 06:49 PM