Re: When reading less than wanted characters, "read" does not detect NUL bytes

2018-06-15 Thread Davide Brini
On Fri, 15 Jun 2018 15:15:23 +0200, Davide Brini wrote: > So it looks like the only "reliable" way to detect NULs in the input is to > read one character at a time. Your explanation got me thinking, and I've come up with the following code that seems to be slightly more efficient than reading on

Re: Bash fails to exit if parent ssh process is killed during command search

2018-06-15 Thread Chet Ramey
On 6/15/18 9:36 AM, Siteshwar Vashisht wrote: > Bash Version: 4.4 > Patch Level: 19 > Release Status: release > > Description: > Bash fails to exit and shows 100% cpu usage if parent sshd process is > killed while performing command search. Thanks for the report. This was fixed in the dev

Bash fails to exit if parent ssh process is killed during command search

2018-06-15 Thread Siteshwar Vashisht
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-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'

Re: When reading less than wanted characters, "read" does not detect NUL bytes

2018-06-15 Thread Davide Brini
On Fri, 15 Jun 2018 09:07:46 -0400, Greg Wooledge wrote: > On Fri, Jun 15, 2018 at 03:03:21PM +0200, Davide Brini wrote: > > $ printf 'a\x00\x00bc' | { while IFS= read -d '' -n 2 var; do echo > > "read: $var, length: ${#var}"; done; } read: a, length: 1 > > read: , length: 0 > > read: bc, length:

Re: When reading less than wanted characters, "read" does not detect NUL bytes

2018-06-15 Thread Greg Wooledge
On Fri, Jun 15, 2018 at 03:03:21PM +0200, Davide Brini wrote: > $ printf 'a\x00\x00bc' | { while IFS= read -d '' -n 2 var; do echo "read: > $var, length: ${#var}"; done; } > read: a, length: 1 > read: , length: 0 > read: bc, length: 2 > > I would expect there to be another read of length 0 betwee

When reading less than wanted characters, "read" does not detect NUL bytes

2018-06-15 Thread Davide Brini
Best explained with an example: $ printf 'a\x00\x00bc' | { while IFS= read -d '' -n 1 var; do echo "read: $var, length: ${#var}"; done; } read: a, length: 1 read: , length: 0 read: , length: 0 read: b, length: 1 read: c, length: 1 This is as expected, and allows detecting a NUL in the input wh