Quoting Nicola Mingotti (nmingotti@gmail.com):
>and this new file will not give the message. With 656 lines, the
>message is there (at least on my machine). What happens is that head
>is able to parse the first line, print it and exit before the ruby
>script has finished writing to its stdout.
Yes Carlo, indeed that was also my hypothesis.
In my opinion that should be changed in Ruby. Because it is not the expected
behaviour
of a command in a shell pipe line.
Even if It is not so a big issue in general to have an un-interesting
error message, it can be annoying. Imagine i have this stuff in a Cron line,
than annoying error message would be mailed to me (boring^2).
In conclusion, I don't think this is an error to send to STDERR.
But before mailing the issue to ruby-core-dev-people I would like to
know if you agree with me this is a legitimate and useful change
to ask.
Well, you must think in perspective of the task you are giving to the
interpreter. You are asking Ruby to write out a bunch of bytes to
stdout regardless. It tries to do that, but the unit it writes to
(which is managed by the shell, thus completely out of control from
its point of view) is suddenly slammed close before it can complete
its task.
In the vast majority of cases in which this sort of circumstance takes
place, I would be quite upset if the Ruby interpreter did not draw my
attention to the event. Which it does by raising an exception.
In special cases, you could always write a little more complex script,
that would catch the exception. For example:
f=File.open("./aggregatoTLX.csv", "r")
s=f.read
begin
puts s
rescue Errno::EPIPE
# Here take whatever measure you wish, or simply do nothing...
end
Carlo
···
Subject: Re: An issue piping to "head"
Date: sab 16 dic 17 07:09:27 +0100
On 16/12/2017 18:48, Carlo E. Prelz wrote:
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)