How to get bash to shut up about SIGPIPE?
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:41:55
Right now my major gripe with cogito is "cg-log" (which is actually the
only command I use right now, everything else I just do by hand with the
raw git archive) is that bash is being an ass about SIGPIPE, and when I
only look at the top part of the log, ie I do something like:
torvalds@ppc970:~/src/cogito> git log | head
it spews out the ten first lines of the log, and then it spews about a
million lines (well, 20, but anyway) of crap:
/home/torvalds/bin/cg-log: line 87: 6338 Done echo -n $color$key $rest
6339 Broken pipe | sed "s/>.*/> ${pdate/+0000/$tz}/"
/home/torvalds/bin/cg-log: line 87: 6328 Done cat-file commit $commit
6329 Broken pipe | while read key rest; do
case "$key" in
"author" | "committer")
if [ "$key" = "author" ]; then
color="$colauthor";
else
color="$colcommitter";
fi; date=(${rest#*> }); sec=${date[0]}; tz=${date[1]}; dtz=${tz/+/}; lsec=$(expr $dtz / 100 \* 3600 + $dtz % 100 \* 60 + $sec); pdate="$(date -Rud "1970-01-01 UTC + $lsec sec" 2>/dev/null)"; if [ "$pdate" ]; then
echo -n $color$key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/"; echo $coldefault;
else
echo $color$key $rest $coldefault;
fi
;;
"")
echo; sed -re '
/
*Signed-off-by:.*/Is//'$colsignoff'&'$coldefault'/
s/./ &/
'
;;
*)
echo $colheader$key $rest $coldefault
;;
esac;
done
which is just incredibly annoying, since it makes the ten lines I actually
_wanted_ to get scroll off the screen..
Damn bash. What's the magic incantation that says SHUT UP!?
Linus