set -e is not suffisant to detect error in pipe context
cat nonexistant | sed s/some//g will hapilly return 0 and do not fail
exec 3>&1; s=$(exec 4>&1 >&3; { cat nonexistant ; echo $? >&4; } | sed s/some//g ) && exit $s
this could be simplified by using make function
PIPESAFE=exec 3>&1; s=$$(exec 4>&1 >&3; { $(1) ; echo $$? >&4; } | $(2)) && exit $$s
Could deserve a footnote on 4.6. Error trapping in makefiles
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 09:37:49 |
Calls: | 10,387 |
Calls today: | 2 |
Files: | 14,060 |
Messages: | 6,416,673 |