[CentOS] Why does 'test -f' and 'test -e' return true on a (hidden) file that doesn't exist?

Mon Mar 31 20:47:52 UTC 2008
Garrick Staples <garrick at usc.edu>

On Mon, Mar 31, 2008 at 04:43:28PM -0400, Marko A. Jennings alleged:
> On Mon, March 31, 2008 4:37 pm, Tim Alberts wrote:
> > Why does 'test -f' and 'test -e' return true on a (hidden) file that
> > doesn't exist?
> >
> > *> cat /home/talberts/.forward*
> > cat: /home/talberts/.forward: No such file or directory
> > *> test -f /home/talberts/.forward ;echo $?*
> > 1
> > *> test -e /home/talberts/.forward ;echo $?*
> > 1
> 
> 0 = exists
> 1 = does not exist

And to expand on that a bit... shell commands do not return the normal boolean
true/false, they return zero for success and non-zero for errors.

Using non-zero for errors is handy for indicating the type or reason for the
error.

-- 
Garrick Staples, GNU/Linux HPCC SysAdmin
University of Southern California

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20080331/b7112cc6/attachment-0004.sig>