[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
read -n option doesn't work right with -u
From: |
b_bashbug |
Subject: |
read -n option doesn't work right with -u |
Date: |
Fri, 7 Dec 2007 00:06:51 -0500 |
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: i686-pc-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O3 -pipe -march=pentium3
-fomit-frame-pointer
uname output: Linux newbie 2.6.17-gentoo-r8 #2 SMP Mon Oct 23 23:53:40 EDT 2006
i686 Pentium III (Coppermine) GenuineIntel GNU/Linux
Machine Type: i686-pc-linux-gnu
Bash Version: 3.2
Patch Level: 17
Release Status: release
Description:
read -u option does not work with -n properly. In particular, it waits
for a newline if fd 0 is closed.
Repeat-By:
Consider:
exec 3<&0
read -n 1 -u 3
This sequence will read a single character from stdin (the terminal)
without waiting for a newline. However, consider
exec 3<&0 0<&-
read -n 1 -u 3
This sequence closes fd 0, and bash waits for a newline before reading
the character.
Note that I am working around this as follows:
exec 3<&0 0<&-
read -n 1 <&3
The preceding works, presumably because it's reading from fd 0 again.
Fix:
I would suspect that the -n option needs to pay attention to the -u
flag, and not just assume fd 0.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- read -n option doesn't work right with -u,
b_bashbug <=