Re: history EINTR bug

2015-02-13 Thread Chet Ramey
On 2/12/15 9:06 AM, gregrwm wrote:
> i now suspect bash does not properly handle EINTR while handling history.

Maybe.  There's not enough information here to say.

> this just happened:
> bash: history: write error: Interrupted system call

What command did you use?  Writing the history to stdout is different
from writing to a pipe, which is different from using history -a or
history -w to write to a file.

It's difficult to say more without knowing which signal interrupted
the command.

Chet

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



process substitution stdout connected to pipeline

2015-02-13 Thread Pádraig Brady
zsh behaves as I expected:
% : | tee >(md5sum) | sha1sum
da39a3ee5e6b4b0d3255bfef95601890afd80709  -
d41d8cd98f00b204e9800998ecf8427e  -

bash though seems to connect the stdout of the process substitution
to the pipeline, which seems like a bug:
$ : | tee >(md5sum) | sha1sum
253a7a49edee354f35b2e416554127cf29c85724  -


cheers,
Pádraig



pipefail with SIGPIPE/EPIPE

2015-02-13 Thread Pádraig Brady
I was expecting bash to handle SIGPIPE specially here,
as in this context it's informational rather than an indication of error.
I.E. if a command to the right actually does fail
the status is set to that fail and the resulting SIGPIPEs
to the left are inconsequential to the status.
If no command fails, then the SIGPIPEs are informational,
and it seems they should also be inconsequential to the status.

  $ set -o pipefail
  $ yes | head -n1 || echo error
  y
  error

cheers,
Pádraig.



Re: process substitution stdout connected to pipeline

2015-02-13 Thread Greg Wooledge
On Fri, Feb 13, 2015 at 05:10:42PM +, Pádraig Brady wrote:
> bash though seems to connect the stdout of the process substitution
> to the pipeline, which seems like a bug:
> $ : | tee >(md5sum) | sha1sum
> 253a7a49edee354f35b2e416554127cf29c85724  -

md5sum inherits the anonymous pipe to sha1sum as its stdout, because
that's how child processes work.  I don't see it as an error in bash,
but rather in the script.  You might want a construction like:

: | tee >(md5sum >&2) | sha1sum

Then you have md5sum writing to bash's stderr, and sha1sum writing to
bash's stdout.  Or you could get fancier with things like 3>&1.