Re: Reading from a file by using its FD returns its contents only once

2018-12-31 Thread mike b
I have the full picture now. Thank you all for your feedback!

Re: Reading from a file by using its FD returns its contents only once

2018-12-31 Thread Chet Ramey
On 12/30/18 8:36 PM, mike b wrote: > Bash Version: 4.4 > Patch Level: 12 > Release Status: release > > I am not quite sure if this is a bug, but here's what I find as a bit odd > behavior: It's not odd. > # modprobe zram num_devices=0 > # exec {add} # read -r id <&"$add"; echo "$id" > 0 > # rea

Re: Reading from a file by using its FD returns its contents only once

2018-12-31 Thread Daniel Mills
On Sun, Dec 30, 2018 at 8:37 PM mike b wrote: > Configuration Information: > 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/sh

Re: Reading from a file by using its FD returns its contents only once

2018-12-31 Thread mike b
That's a good point, I haven't thought about it like this. I always thought that each read always starts at the beginning of the file given fd points at. So the fact that it changes offset is a bit surprising: # echo word >t # exec {in} napisaƂ(a): > On Mon, Dec 31, 2018 at 2:37 AM mike b wrote:

Re: Reading from a file by using its FD returns its contents only once

2018-12-31 Thread Tadeus Prastowo
On Mon, Dec 31, 2018 at 2:37 AM mike b wrote: [...] > The above is just an example. Doing reads on any other regular file like > this yields same behavior: > # echo bla >./t > # exec 10<./t > # read -r <&10 > # echo $REPLY > bla > # read -r <&10 > # echo $REPLY That's correct behavior because t

Reading from a file by using its FD returns its contents only once

2018-12-30 Thread mike b
Configuration Information: 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