Re: test -f with no args is true

2006-04-15 Thread Bob Proulx
Chet Ramey wrote: > Bob Proulx wrote: > > As an alternative, you could use the [[ ... ]] syntax. That is the > > newer syntax, covered in POSIX too so should be portable to POSIX > > systems, but is always a built-in to the shell. > > POSIX declined to standardize [[...]]. It just happens to app

Re: test -f with no args is true

2006-04-15 Thread Chet Ramey
Bob Proulx wrote: > As an alternative, you could use the [[ ... ]] syntax. That is the > newer syntax, covered in POSIX too so should be portable to POSIX > systems, but is always a built-in to the shell. POSIX declined to standardize [[...]]. It just happens to appear in `posix shells' descend

Re: test -f with no args is true

2006-04-15 Thread Bob Proulx
Charlie Bennett wrote: > H. I sat on that blasted committee. :-) > I'll file a corrigendum or whatever it's called. This should at > least be called out in the rationale. > > No biggie. I'll just make sure I quote all of my args. Yes, because test and [ were external commands when the AP

Re: test -f with no args is true

2006-04-15 Thread cbennett
H. I sat on that blasted committee. I'll file a corrigendum or whatever it's called. This should at least be called out in the rationale. No biggie. I'll just make sure I quote all of my args. ccb > Charlie Bennett wrote: >> Is this expected behavior? >> >> [EMAIL PROTECTED] .ssh]# [ -

Re: test -f with no args is true

2006-04-15 Thread Paul Jarc
Charlie Bennett <[EMAIL PROTECTED]> wrote: > Is this expected behavior? > > [EMAIL PROTECTED] .ssh]# [ -f ] > [EMAIL PROTECTED] .ssh]# echo $? > 0 Yes. A single argument is considered true if it is not the mepty string, even if it happens to coincide with the spelling of an operator. This is ho

Re: test -f with no args is true

2006-04-15 Thread Bob Proulx
Charlie Bennett wrote: > Is this expected behavior? > > [EMAIL PROTECTED] .ssh]# [ -f ] > [EMAIL PROTECTED] .ssh]# echo $? > 0 Yes. That is expected behavior. With one argument the return code is true if the string is non-zero in length. The case covered is this case: if [ "$variable" ]; t

Re: test -f with no args is true

2006-04-15 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Charlie Bennett on 4/14/2006 9:17 AM: > Is this expected behavior? > > [EMAIL PROTECTED] .ssh]# [ -f ] > [EMAIL PROTECTED] .ssh]# echo $? > 0 Yes. POSIX requires 'test' (aka '['), when handed exactly one argument, to return 0 if it is