[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Glob returns a value when no match occurs
From: |
Chad Lake |
Subject: |
Glob returns a value when no match occurs |
Date: |
Mon, 13 Jan 2003 12:28:28 -0700 |
This sure seems like a bug to me:
[573] belay:~:> which foo
foo is a function
foo ()
{
arr=(*.txt);
echo "${#arr[@]} files found:";
for x in "${arr[@]}";
do
echo " $x";
done
}
[574] belay:~:> touch foo.txt bar.txt baz.txt
[575] belay:~:> foo
3 files found:
bar.txt
baz.txt
foo.txt
[576] belay:~:> \rm *.txt
[577] belay:~:> foo
1 files found:
*.txt
[578] belay:~:>
Looks like the glob "arr=(*.txt)" is actually returning the string
"*.txt" when no match occurs. Either that or the array definition is
picking up on the string when no match occurs. In either case, this
is aberrant behavior. Either let the * glob, or don't, but don't mix
the two. ;)
-c
- Glob returns a value when no match occurs,
Chad Lake <=