bug-bash
[Top][All Lists]
Advanced

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

Re: test -t


From: Paul Jarc
Subject: Re: test -t
Date: Wed, 03 Sep 2008 13:01:56 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

jidanni@jidanni.org 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:
    String operators:
...
        STRING         True if string is not empty.

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.

> $ t=test #bash builtin
> $ $t -t ' '; echo $?
> 0

That looks like a bug.  bash tries to parse a number from the " "
string and ends up with zero, which is a tty.


paul




reply via email to

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