rakitzis / rc

rc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
Other
250 stars 23 forks source link

grep -q causes sigpipe #73

Closed maxice8 closed 3 years ago

maxice8 commented 3 years ago

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

rakitzis commented 3 years ago

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.

maxice8 commented 3 years ago

Thanks for the quick explanation