[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed, SIGPIPE, cmp -s [Re: [PATCH 3/4] gnulib-tool: abort loops early
From: |
Bruno Haible |
Subject: |
Re: sed, SIGPIPE, cmp -s [Re: [PATCH 3/4] gnulib-tool: abort loops early where possible. |
Date: |
Thu, 1 Jan 2009 20:47:03 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Jim,
> ./bootstrap: Copying ._bootmp/gnulib-tests/Makefile.am to
> gnulib-tests/gnulib.mk...
> -sed: couldn't write 60 items to stdout: Broken pipe
> +sed: couldn't write 56 items to stdout: Broken pipe
>
> I see that it's technically harmless and comes from here:
>
> sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
> echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
>
> because using GNU cmp's -s (--silent/ exit-status-only) option
> makes it refrain from reading all input, so sed's write evokes SIGPIPE.
>
> I may take this as encouragement not to use -s,
> and just redirect to /dev/null instead.
The purpose of SIGPIPE is to speed up pipes of commands. By piping
cmp's result to /dev/null you renounce this optimization. In order to
exploit this optimization, without getting bash's error message, all
you need is func_reset_sigpipe from gnulib-tool, and
(func_reset_sigpipe
sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." && ... }
)
Let me add one more comment:
2009-01-01 Bruno Haible <address@hidden>
* gnulib-tool (func_reset_sigpipe): Add more comments.
*** gnulib-tool.orig 2009-01-01 20:40:45.000000000 +0100
--- gnulib-tool 2009-01-01 20:40:21.000000000 +0100
***************
*** 578,584 ****
# will read from this pipe might prematurely exit or close its standard input
# descriptor.
if test -n "$BASH_VERSION"; then
! # The problem has only been reported with bash.
# Note that Solaris sh does not understand "trap - SIGPIPE".
func_reset_sigpipe ()
{
--- 578,586 ----
# will read from this pipe might prematurely exit or close its standard input
# descriptor.
if test -n "$BASH_VERSION"; then
! # The problem has only been reported with bash. Probably it occurs only with
! # bash-3.2. For the reasons, see
! # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
# Note that Solaris sh does not understand "trap - SIGPIPE".
func_reset_sigpipe ()
{
- Re: sed, SIGPIPE, cmp -s [Re: [PATCH 3/4] gnulib-tool: abort loops early where possible.,
Bruno Haible <=
- Re: sed, SIGPIPE, cmp -s [Re: [PATCH 3/4] gnulib-tool: abort loops early where possible., Jim Meyering, 2009/01/01
- Re: bash, sed, SIGPIPE, Bruno Haible, 2009/01/01
- Re: bash, sed, SIGPIPE, Eric Blake, 2009/01/01
- Re: bash, sed, SIGPIPE, Bruno Haible, 2009/01/01
- Re: bash, sed, SIGPIPE, Jim Meyering, 2009/01/02