Re: How to get bash to shut up about SIGPIPE?

From: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Date: 2005-04-30 21:04:10
On Fri, Apr 29, 2005 at 11:29:22PM -0700, Paul Jackson wrote:
> Linus replied to pj:
> > > Code Sample 2:
> > > ...
> > Didn't change anything for me. Same thing.
> 
> I don't believe you did what I did.
> 
> The source code for bash, both 2.x and 3.x versions, clearly displays a
> simpler error message (no line number or redisplay of your script
> commands) in the case that you set a trap.  And I tested both shells on
> a multiprocessor, to verify that they behaved as I expected, running
> these silly little scripts.

I don't have a multiprocessor and I see the same.  Are you sure it's SMP
dependant?

Your solution (trapping _inside_ the job, too) works for me, btw.  Here's
a patch for cg-log that reduces the clutter to two "Broken pipe" lines
(pun not intended).

Rene


--- cg-log~	2005-04-29 23:43:09.000000000 +0200
+++ cg-log	2005-04-30 12:15:40.000000000 +0200
@@ -16,6 +16,7 @@
 # or id1:id2 representing an (id1;id2] range of commits to show.
 
 . cg-Xlib
+trap exit SIGPIPE
 
 if [ "$1" = "-c" ]; then
 	shift
@@ -47,6 +48,7 @@
 fi
 
 $revls | $revsort | while read time commit parents; do
+	trap exit SIGPIPE
 	[ "$revfmt" = "rev-list" ] && commit="$time"
 	echo $colheader""commit ${commit%:*} $coldefault;
 	cat-file commit $commit | \
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Sat Apr 30 21:04:23 2005

This archive was generated by hypermail 2.1.8 : 2005-04-30 21:04:24 EST