bug-bash
[Top][All Lists]
Advanced

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

Re: Builtin read with -n0 or -N0 (nchars == 0) behaves as a read with no


From: Pranav Deshpande
Subject: Re: Builtin read with -n0 or -N0 (nchars == 0) behaves as a read with no -n/-N argument
Date: Sun, 4 Jun 2017 10:50:16 +0530

Is that more advantageous?

On Sun, Jun 4, 2017 at 10:46 AM, dualbus <address@hidden> wrote:

> On Sun, Jun 04, 2017 at 01:45:42AM +0530, Pranav Deshpande wrote:
> [...]
> > My solution is to change *line 294* of builtins/read.def.
> >
> > Change
> > if (code == 0 || *intval < 0* || intval != (int)intval)
> >
> > to
> >
> > if (code == 0 || i*ntval <= 0* || intval != (int)intval)
> [...]
>
> > Is this solution ok?
>
> Yes. That works.
>
>
> Chet went with the other option though:
>
>   address@hidden:~/src/gnu/bash-build$ ./bash -c 'read -n0; echo $?;
> declare -p REPLY'
>   0
>   declare -- REPLY=""
>
> You can see the change by navigating the `devel' branch of the git
> repository
> in Savannah (commit 1110e30870a8782425067a060d89cc411b014418):
>
>   http://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=
> 1110e30870a8782425067a060d89cc411b014418
>
> Although there's a problem with the solution:
>
>   address@hidden:~$ for sh in bash ~/src/gnu/bash-build/bash ksh93 mksh;
> do $sh -c ': | read -n 0; echo $?'; done
>   1
>   0
>   1
>   1
>
> Since the read(2) system call doesn't take place, `read -n 0' doesn't
> detect
> the broken pipe. IMO, it should.
>
> --
> Eduardo Bustamante
> https://dualbus.me/
>


reply via email to

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