[ubuntu-za] Script error
Neil Muller
neil at dip.sun.ac.za
Tue Apr 14 14:40:20 BST 2009
On Tue, Apr 14, 2009 at 03:37:17PM +0200, Neil Muller wrote:
> On Tue, Apr 14, 2009 at 03:03:09PM +0200, Walter Leibbrandt wrote:
> > ... Or zero.
> >
> > 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
> 0
> $ unset UNDEFINED # UNDEFINED is null
> $ [ -f $UNDEFINED ] ; echo $? # still test for existance, even though null
> 1
Which is of course completely and utterly wrong - if UNDEFINED is null,
this evaluates to [ -f ], and succeeds. (I ran the above command in the
wrond shell, where UNDEFINED was defined (don't ask), and got the wrong
results).
--
Neil Muller email: neil at dip.sun.ac.za
Division Applied Mathematics, Department of Mathematical Sciences
University of Stellenbosch
More information about the ubuntu-za
mailing list