bug-bash
[Top][All Lists]
Advanced

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

[doc] read -t and sockets, devices...


From: Stephane Chazelas
Subject: [doc] read -t and sockets, devices...
Date: Thu, 05 Jun 2008 15:55:51 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux sc.homeunix.net 2.6.25-rc8 #1 PREEMPT Fri Apr 4 08:56:07 
BST 2008 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

Description:
        Hiya,

        the doc says:

            -t timeout Cause read to time out and return failure if
            a complete line of input is not read within timeout
            seconds. This option has no effect if read is not
            reading input from the terminal or a pipe.

        However, I find that it does have an effect on Unix or
        TCP sockets, on /dev/random and other terminals than
        "the" terminal.


        So maybe a better wording could be: "This option has no
        effect on regular files"?

        Also, it may be good to specify that, if the timeout is
        reached, bash will consume the input but will not put
        that consumed input into the variable:

$ (printf xxxx; sleep 2; printf 'yyyy\n') | bash -c 'read -t1 a; echo "<$a>"; 
cat'
<>
yyyy

        Also, is their a way to differenciate between "timeout"
        and "eof"? Looks like the exit status is 1 in both
        cases.

        Like in:

        sleep 1 | bash -c 'read -t2'
        and
        sleep 2 | bash -c 'read -t1'


Best regards,
Stephane




reply via email to

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