Re: Bug with && in piped functions in minimal-config bash

2016-11-05 Thread Chet Ramey
On 11/4/16 5:41 PM, Martijn Dekker wrote:
> My development with Modernish just exposed the following bug on bash
> 4.4.0(1)-maint, bash-20161028 snapshot, compiled with
> --enable-minimal-config --enable-alias:
> 
> $ fn() { false && echo bug || echo ok; }
> $ fn
> ok
> $ fn
> ok
> $ fn | cat
> ok
> $ fn | cat
> bug

Thanks for the report.  This is an easy fix; similar to that from 9/23
based on your bug report then.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: Bug with && in piped functions in minimal-config bash

2016-11-04 Thread Martijn Dekker
Op 04-11-16 om 21:41 schreef Martijn Dekker:
> $ fn() { false && echo bug || echo ok; }
> $ fn
> ok
> $ fn
> ok
> $ fn | cat
> ok
> $ fn | cat
> bug
> $ fn | cat
> bug
> $ (fn) | cat
> ok

Another datapoint: the result and output is exactly as above even if you
use if/then/else.

fn() { if false; then echo bug; else echo ok; fi; }

Thanks,

- M.




Bug with && in piped functions in minimal-config bash

2016-11-04 Thread Martijn Dekker
My development with Modernish just exposed the following bug on bash
4.4.0(1)-maint, bash-20161028 snapshot, compiled with
--enable-minimal-config --enable-alias:

$ fn() { false && echo bug || echo ok; }
$ fn
ok
$ fn
ok
$ fn | cat
ok
$ fn | cat
bug
$ fn | cat
bug
$ (fn) | cat
ok

So apparently this only occurs if the function is piped into another
command, without explicitly declaring it to run in a subshell, and only
from the second time on.

Thanks,

- M.