No, globs are not expanded when quoted, so:
set -- '*.txt'
[ -f "$1" ]
Will check whether the file called
*.txt in the current directory is a regular file or a symlink to a regular file.
[ -f $1 ]
would be a problem (
$1 would undergo word splitting (here not doing anything with the default value of
$IFS) and filename generation).
If you wanted to check whether there were regular files with a
.txt extension, you'd need a loop or use
zsh glob qualifiers.
set -- *.txt
for f do
if [ -f "$f" ]; then
echo "there is at least one regular file with a .txt extension here"
Or if the pattern is found in
IFS= # disable the globbing part of the split+glob operator
set -- $1
for f do... # as above
echo "$#files regular files with a .txt extension here"
find -L . ! -name . -prune ! -name '.*' -name '*.txt' -type f | grep -q . &&
echo there are regular .txt files in here