Page MenuHomeFreeBSD

Mk/Scripts/ Turn off pipefail when piping to grep -q
Needs ReviewPublic

Authored by jrm on Sun, Jul 18, 2:14 AM.


Group Reviewers

The pipeline

readelf -d "${dep_file}" | grep -q SONAME

can fail because grep -q closes the output early resulting sigpipe being
sent to readelf. Other possible solutions are to turn off pipefail for
the file or remove the -q grep argument.

Credit to ashish@ for the detective work on discovering the root cause
of this.

Diff Detail

rP FreeBSD ports repository
No Linters Available
No Unit Test Coverage
Build Status
Buildable 40722
Build 37611: arc lint + arc unit

Event Timeline

jrm requested review of this revision.Sun, Jul 18, 2:14 AM

FWIW, I also came across it some time ago while working on www/qt5-webengine. The issue with grep -q can be reproduced quite well on i386 platforms with quite large files and I had already created a PoC for this, but since then I haven't had time to follow it up more closely.

Please add a comment about why it is disabled, otherwise it ends up being new magic that nobody knows why it is there.

Add a comment describing why pipefail is turned off when piping to grep -q.

foo | grep -q is a pretty common idiom so I worry that there could be many instances of this issue, not just readelf