Re: [PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-10 Thread Chet Ramey
On 7/8/23 3:18 AM, Stephane Chazelas wrote: 2023-07-07 15:52:28 -0400, Chet Ramey: [...] Historical versions of test made the argument to -t optional here. I can continue to support that in default mode for backwards compatibility, but it will be an error in posix mode. [...] I think you may h

Re: [PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-08 Thread Stephane Chazelas
2023-07-07 15:52:28 -0400, Chet Ramey: [...] > Historical versions of test made the argument to -t optional here. I can > continue to support that in default mode for backwards compatibility, but > it will be an error in posix mode. [...] I think you may have overlooked the bottom part of my email

Re: [PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-07 Thread Chet Ramey
On 7/6/23 2:29 AM, Stephane Chazelas wrote: Hello, Thanks for the report. test -t X Always returns false and doesn't report an error about that invalid number (beside the point here, but in ksh/zsh, that X is treated as an arithmetic expression and evaluates to 0 if $X is not set).

[PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-05 Thread Stephane Chazelas
Hello, test -t X Always returns false and doesn't report an error about that invalid number (beside the point here, but in ksh/zsh, that X is treated as an arithmetic expression and evaluates to 0 if $X is not set). While: test -t X -a Y returns a "too many arguments" error.

Re: test -t

2008-09-07 Thread Paul Jarc
Chet Ramey <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: >> Is this a bug? >> $ t=test #bash builtin $ $t -t ' '; echo $? 0 > > Doesn't look like it: I think it is a bug, but libc may or may not hide it, depending on the strtol[l] implementation. SUS says: # If the subjec

Re: test -t

2008-09-03 Thread Chet Ramey
[EMAIL PROTECTED] wrote: > Is this a bug? > >>> $ t=test #bash builtin >>> $ $t -t ' '; echo $? >>> 0 Doesn't look like it: $ ../bash-3.2-patched/bash --version GNU bash, version 3.2.39(3)-release (i386-apple-darwin9.2.0) Copyright (C) 2007 Fr

Re: test -t

2008-09-03 Thread jidanni
Is this a bug? >> $ t=test #bash builtin >> $ $t -t ' '; echo $? >> 0 PJ> That looks like a bug. bash tries to parse a number from the " " PJ> string and ends up with zero, which is a tty.

Re: test -t

2008-09-03 Thread Chet Ramey
Paul Jarc wrote: > Similar language is in bash's man page and coreutils' info > documentation. But it wouldn't hurt to add a note to indicate that if > no operand is provided, then "-t" and other operators stop being > operators, and are tested as plain strings. This is covered in the man page a

Re: test -t

2008-09-03 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > On (info "(coreutils)File type tests", and test(1) man page, we see > `-t FD' >True if FD is a file descriptor that is associated with a terminal. > > Well please mention what happens if FD is omitted: bash's "help test" explains this, if you know where to look

test -t

2008-09-03 Thread jidanni
On (info "(coreutils)File type tests", and test(1) man page, we see `-t FD' True if FD is a file descriptor that is associated with a terminal. Well please mention what happens if FD is omitted: $ test -t The answer is it always returns true, no matter what. Test with $ ec