[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error in read implementation and/or documentation
From: |
Pierre Gaston |
Subject: |
Re: Error in read implementation and/or documentation |
Date: |
Sat, 27 Jul 2013 18:17:51 +0300 |
On Sat, Jul 27, 2013 at 7:37 AM, Peter Olson <polson136@gmail.com> wrote:
> According to "help read":
> Options:
> -n nchars return after reading NCHARS characters rather than
> waiting
> for a newline, but honor a delimiter if fewer than NCHARS
> characters are read before the delimiter
>
> Exit Status:
> The return code is zero, unless end-of-file is encountered, read
> times out,
> or an invalid file descriptor is supplied as the argument to -u.
>
> If read is invoked with the -n or -N options, then given an EOF, it returns
> with a zero exit status.
>
> In addition, if it is invoked with -n 3, for example, then given EOF for one
> of the first 2 characters, it still waits for all 3 characters.
>
> I am running the most recent Arch (up to date as of 7/26/13) on a 64-bit
> machine.
> Arch package version: 4.2.045-4
> $BASH_VERSION: 4.2.45(2)-release
>
> Is it possible that this can be fixed? Any suggestions for a work-around if
> it can't?
>
> Peter Olson
>
>
What is your test case?
I don't seem to be able to reproduce your problems, read returns
when it encouters EOF, and I get 1 if fewer bytes are read
$ printf 12 | { read -n4; echo $?;read -n4;echo $?; }
1
1