< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #14413 has been updated by nobu (Nobuyoshi Nakada).
It didn't work with `END {}`.
```ruby
# silent_epipe.rb
# -*- frozen-string-literal :true -*-
BEGIN {
if Errno.const_defined?("EPIPE") and Signal.list["PIPE"]
class SystemCallError
prepend Module.new {
sigpipe = SignalException.new("PIPE").freeze
define_method(:exception) {Errno::EPIPE === self ? sigpipe : super}
}
end
end
}
```
```
$ yes | ruby -w -r./silent_epipe -pe 'END{STDERR.puts :END}' | head -1; echo ${PIPESTATUS[@]}
y
END
141 141 0
```
----------------------------------------
Bug #14413: `-n` and `-p` flags break when stdout is closed
https://bugs.ruby-lang.org/issues/14413#change-69947
* Author: josh.cheek (Josh Cheek)
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-darwin16]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Ruby generally works well within a pipeline. The `-n` and `-p` flags are incredibly useful. However, it is common practice to use programs like `head` and `sed`, which will close the pipe after completing their job. This is convenient, because often it limits an expensive amount of output to a workable subset. I can figure out the pipeline for a subset of input, and then remove the limiting function.
However, Ruby explodes with `-e:1:in `write': Broken pipe @ io_write - <STDOUT> (Errno::EPIPE)`, when it writes the current line to stdout. When in a line oriented mode, and stdout closes, I think it should exit successfully (so it doesn't break bash scripts with `pipe fail`set) and silently (no error message), hence marking this a bug report rather than a feature request.
I've attached a screenshot to show that this is how every other program works, that I tried.
~~~
git clone https://github.com/jquery/esprima
cd esprima/test/fixtures/
ls | head -1 # ls
find . -type f -name '*json' | head -1 # find
find . -type f -name '*json' | head -1 | xargs cat | jq . | head -1 # jq
find . -type f -name '*json' | grep -v JSX | grep -v tokenize | head -1 # grep
find . -type f -name '*json' | sed -E '/JSX|tokenize/d' | head -1 # sed
find . -type f -name '*json' | awk '/JSX|tokenize/ { next }; { print }' | head -1 # awk
find . -type f -name '*json' | perl -e 'while(<>) { /JSX|tokenize/ || print }' | head -1 # perl
find . -type f -name '*json' | ruby -ne 'print unless /JSX|tokenize/' | head -1 # ruby :(
~~~
---Files--------------------------------
Screen Shot 2018-01-27 at 7.27.49 PM.png (458 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>