bug-bash
[Top][All Lists]
Advanced

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

test -f with no args is true


From: Charlie Bennett
Subject: test -f with no args is true
Date: Fri, 14 Apr 2006 11:17:57 -0400

I'm running bash 3.0.  I'm seeing the same thing in
the Fedora 4 distributed version and in a copy built
from the stable tarball.

Is this expected behavior?

[root@build-04 .ssh]# [ -f  ]
[root@build-04 .ssh]# echo $?
0

All of the file test ops behave the same way.


in test.c, we call posixtest()

posixtest() sees one arg and calls ONE_ARG_TEST which
is a 'presence' test, effectively the opposite of -z.

This can never work.

Here's a hack fix:

[root@cbennett-D800 bash-3.0]# diff test.c test.c.orig
799,820c799
<
< #define ONE_ARG_TEST(s)  ( one_arg_allowed( (s) ) && (s)[0] != '\0' )
<
< static int one_arg_allowed( char *s ) {
<
<   char *unaries = "bcdefghGkLOnprsStuwx";
<
<   if( s[0] != '-' ) {
<     /* not a potential switch */
<     return(TRUE);
<   }
<   if( s[1] == '\0' ) {
<     /* solo '-', this is a "string presence" test */
<     return(TRUE);
<   }
<   if( NULL == index( unaries, s[1] ) ) {
<     return(TRUE);
<   }
<   test_syntax_error( _("%s: argument expected"), s);
<   return(FALSE);
< }
<
---
> #define ONE_ARG_TEST(s)               ((s)[0] != '\0')






reply via email to

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