Rob Hudson wrote,
>If I run this:
>
># for i in ~/.maildir/cur/* ; do echo $i ; done
>~/.maildir/cur/1142021402.V810I1560adeM187221:2,S
>
>I get a list of the files in that directory.
>
>If there are no files in the directory, I get my glob back...
>
># for i in ~/.maildir/new/* ; do echo $i ; done
>~/timesheet/.maildir/new/*
>
>Is there a way to *not* get this glob back? If the dir is empty, the
>command I have is getting this glob and is throwing an error.
>
>If I can't change that behavior I'll have to change my script to handle
>and ignore the glob. But I'd prefer to not get the glob if possible.
Add this to the plethora of answers you've already received:
shopt -s nullglob
for i in ~/.maildir/new/*; do echo $i; done
The "nullglob" option tells bash that it's OK for a wildcard to expand
to nothing at all.
Once set, the "nullglob" state lasts until the end of the script, or until
explicitly unset ("shopt -u nullglob"), whichever comes first.
- Neil Parker
_______________________________________________
EUGLUG mailing list
[email protected]
http://www.euglug.org/mailman/listinfo/euglug