[ubuntu-za] Script error

Walter Leibbrandt walter+ubuntuza at translate.org.za
Tue Apr 14 14:25:14 BST 2009

Russell Cloran wrote:
> An asterisk glob will never "expand" to zero length, but will rather
> leave the * as is...
> russell at stratus:~/tmp$ touch ubuntu
> russell at stratus:~/tmp$ echo *buntu
> ubuntu
> russell at stratus:~/tmp$ echo *Ubuntu
> *Ubuntu
> I promise I didn't cheat and create a file called "*Ubuntu" ;)
Oh yeah... forgot that. :P
>> The following seems to always echo 1, ie. -f returns true if no
>> parameters are specified:
>> if [ -f ]; then echo 1; else echo 0; fi
> Of course, an asterisk glob which was not expanded means that the file
> doesn't exist and your -f will be false anyways.
> Russell
Hmmm... not according to these:
$ if [ -f ]; then echo 1; else echo 0; fi
$ if [ -f x* ]; then echo 1; else echo 0; fi

And yes, there is no x* files. ;) That made me believe that -f always
returns true for no arguments, even an unexpanded blob (like x*) returns
false, because the file "x\*" does not exist.

Or am I missing something?

Walter Leibbrandt                  Software Developer
Recent blogs:
* Firefox-style button with a pop-up menu

More information about the ubuntu-za mailing list