bug-bash
[Top][All Lists]
Advanced

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

0xFF and read -N


From: Stephane Chazelas
Subject: 0xFF and read -N
Date: Sat, 31 Aug 2013 20:13:11 +0100

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-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  
-D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
-Werror=format-security -Wall
uname output: Linux sc 3.10-2-amd64 #1 SMP Debian 3.10.5-1 (2013-08-07) x86_64 
GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

When called with the -N option, "read" seems to consider the byte 0xFF
as meaning EOF (well, not exactly since it doesn't set the exit status to
non-zero):

OK$ printf '\376' | LC_ALL=C bash -c 'IFS= read -rN1 a; printf %s "$a"' | od 
-tx1
0000000 fe
0000001
NOK$ printf '\377' | LC_ALL=C bash -c 'IFS= read -rN1 a; printf %s "$a"' | od 
-tx1
0000000

NOK$ printf 'xx\377xx' | LC_ALL=C bash -c 'IFS= read -rN5 a; printf %s "$a"' | 
od -tc
0000000   x   x
0000002

The problem doesn't occur with -n instead.

-- 
Stephane



reply via email to

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