bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test -f with no args is true


From: Eric Blake
Subject: Re: test -f with no args is true
Date: Sat, 15 Apr 2006 12:51:49 -0600
User-agent: Thunderbird 1.5 (Windows/20051201)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Charlie Bennett on 4/14/2006 9:17 AM:
> Is this expected behavior?
> 
> [root@build-04 .ssh]# [ -f  ]
> [root@build-04 .ssh]# echo $?
> 0

Yes.  POSIX requires 'test' (aka '['), when handed exactly one argument,
to return 0 if it is non-empty and 1 if it is empty.  Since "-f" is two
characters, it is non-empty and returns true.  It is only a file test if
there are two arguments handed to 'test'.

> Here's a hack fix:

And the hack is wrong, because it would violate POSIX semantics.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEQUDF84KuGfSFAYARAt6eAJ4+IBL0GsARdpZuK3D3NhEZCRnY0ACeLeLj
wSIAHs92UqGHXL5dQnE9+q0=
=SVWs
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]