rakitzis/rc

grep -q causes sigpipe

maxice8 opened this issue · 2 comments

trying

if(strings $binary | grep -q -x archive/zip) echo $binary

always fail since the resulting status is sigpipe 0, the same does not happen if one uses grep -x archive/zip >/dev/null

This is the documented behavior of pipeline statuses.

The exit status of a pipeline is considered true if and only if every
command in the pipeline exits true.

The sigpipe occurs because grep is exiting early, so strings writes to a broken pipe.

Thanks for the quick explanation