bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: updating copyright years


From: Joel E. Denny
Subject: Re: updating copyright years
Date: Wed, 5 Aug 2009 14:22:11 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Wed, 5 Aug 2009, Eric Blake wrote:

> > +if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null;
> > then
> > +  compare() { diff -u "$@"; }
> 
> 'diff -u' is required by POSIX 2008.  Rather than filtering on
> whether 'diff --version' includes GNU, it would be better to
> filter on whether 'diff -u' is accepted on the command line,
> to allow other POSIX-compliant implementations their chance.
> Something like 'diff -u /dev/null /dev/null' giving no output
> and having a 0 status should be a sufficient filter.

Thanks.  Here's a revised version.

>From 9df97231a6824ab608751e61b05c36279719a21a Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Wed, 5 Aug 2009 10:03:10 -0400
Subject: [PATCH] update-copyright-tests: improve portability

* tests/test-update-copyright.sh: Use cmp if diff cannot handle
-u or /dev/null.  Suggested by Jim Meyering and Eric Blake.
---
 ChangeLog                      |    6 +++
 tests/test-update-copyright.sh |   83 +++++++++++++++++++++------------------
 2 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index da9a2bd..225df2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-05  Joel E. Denny  <address@hidden>
+
+       update-copyright-tests: improve portability
+       * tests/test-update-copyright.sh: Use cmp if diff cannot handle
+       -u or /dev/null.  Suggested by Jim Meyering and Eric Blake.
+
 2009-08-03  Joel E. Denny  <address@hidden>
 
        update-copyright: support @copyright{} and &copy;
diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh
index 00ae5da..3d157ad 100755
--- a/tests/test-update-copyright.sh
+++ b/tests/test-update-copyright.sh
@@ -16,6 +16,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+diffout=`diff -u /dev/null /dev/null 2>&1`
+if test x"$diffout" = x"" && test $? -eq 0; then
+  compare() { diff -u "$@"; }
+else
+  compare() { cmp "$@"; }
+fi
+
 TMP_BASE=update-copyright.test
 
 ## ----------------------------- ##
@@ -53,33 +60,33 @@ EOF
 
 UPDATE_COPYRIGHT_YEAR=2009 \
   update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u - $TMP-stderr <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare - $TMP-stderr <<EOF || exit 1
 $TMP.4: warning: FSF copyright statement not found
 $TMP.5: warning: FSF copyright statement not found
 EOF
-diff -u - $TMP.1 <<EOF || exit 1
+compare - $TMP.1 <<EOF || exit 1
 Copyright @copyright{} 1990-2005, 2007-2009 Free Software
 Foundation, Inc.
 EOF
-diff -u - $TMP.2 <<EOF || exit 1
+compare - $TMP.2 <<EOF || exit 1
 # Copyright (C) 1990-2005, 2007-2009 Free Software
 # Foundation, Inc.
 EOF
-diff -u - $TMP.3 <<EOF || exit 1
+compare - $TMP.3 <<EOF || exit 1
 /*
  * Copyright &copy; 90,2005,2007-2009
  * Free Software Foundation, Inc.
  */
 EOF
-diff -u - $TMP.4 <<EOF || exit 1
+compare - $TMP.4 <<EOF || exit 1
 /* Copyright (C) 1990-2005, 2007-2009 Free Software
  * Foundation, Inc.  */
 
 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
 Inc.
 EOF
-diff -u - $TMP.5 <<EOF || exit 1
+compare - $TMP.5 <<EOF || exit 1
 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
 
 # Copyright (C) 1990-2005, 2007-2009 Free Software
@@ -88,31 +95,31 @@ EOF
 
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP.* 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u - $TMP-stderr <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare - $TMP-stderr <<EOF || exit 1
 $TMP.4: warning: FSF copyright statement not found
 $TMP.5: warning: FSF copyright statement not found
 EOF
-diff -u - $TMP.1 <<EOF || exit 1
+compare - $TMP.1 <<EOF || exit 1
 Copyright @copyright{} 1990-2005, 2007-2010 Free Software Foundation,
 Inc.
 EOF
-diff -u - $TMP.2 <<EOF || exit 1
+compare - $TMP.2 <<EOF || exit 1
 # Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc.
 EOF
-diff -u - $TMP.3 <<EOF || exit 1
+compare - $TMP.3 <<EOF || exit 1
 /*
  * Copyright &copy; 90, 2005, 2007-2010 Free Software Foundation, Inc.
  */
 EOF
-diff -u - $TMP.4 <<EOF || exit 1
+compare - $TMP.4 <<EOF || exit 1
 /* Copyright (C) 1990-2005, 2007-2009 Free Software
  * Foundation, Inc.  */
 
 Copyright (C) 1990-2005, 2007-2009 Free Software Foundation,
 Inc.
 EOF
-diff -u - $TMP.5 <<EOF || exit 1
+compare - $TMP.5 <<EOF || exit 1
 Copyright (C) 1990-2005, 2007-2009 Acme, Inc.
 
 # Copyright (C) 1990-2005, 2007-2009 Free Software
@@ -133,9 +140,9 @@ cat > $TMP <<EOF
 '\" Inc.
 EOF
 update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u /dev/null $TMP-stderr || exit 1
-diff -u - $TMP <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare /dev/null $TMP-stderr || exit 1
+compare - $TMP <<EOF || exit 1
 '\" Copyright (C) 2006, $YEAR Free Software Foundation, Inc.
 EOF
 rm $TMP*
@@ -154,9 +161,9 @@ dnl   Undisturbed text.
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u /dev/null $TMP-stderr || exit 1
-diff -u - $TMP <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare /dev/null $TMP-stderr || exit 1
+compare - $TMP <<EOF || exit 1
     Undisturbed text.
 dnl Undisturbed text.
 dnl Copyright (C) 1989, 2010 Free Software Foundation, Inc.
@@ -176,9 +183,9 @@ cat > $TMP <<EOF
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u /dev/null $TMP-stderr || exit 1
-diff -u - $TMP <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare /dev/null $TMP-stderr || exit 1
+compare - $TMP <<EOF || exit 1
 #### Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984,
 #### 1985, 1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 #### 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
@@ -197,11 +204,11 @@ cat > $TMP <<EOF
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u - $TMP-stderr <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare - $TMP-stderr <<EOF || exit 1
 $TMP: warning: FSF copyright statement not found
 EOF
-diff -u - $TMP <<EOF || exit 1
+compare - $TMP <<EOF || exit 1
 ####  Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
 ####  1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
 ####  2008 Free Software Foundation, Inc.
@@ -226,11 +233,11 @@ Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 
1983, 1984, 1985,
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u - $TMP-stderr <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare - $TMP-stderr <<EOF || exit 1
 $TMP: warning: FSF copyright statement not found
 EOF
-diff -u - $TMP <<EOF || exit 1
+compare - $TMP <<EOF || exit 1
 #Copyright (C) 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
 #
 #1986, 1987, 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
@@ -255,9 +262,9 @@ cat > $TMP <<EOF
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u /dev/null $TMP-stderr || exit 1
-diff -u - $TMP <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare /dev/null $TMP-stderr || exit 1
+compare - $TMP <<EOF || exit 1
        Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
        98, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
        2009-2010 Free Software Foundation, Inc.
@@ -276,9 +283,9 @@ cat > $TMP <<EOF
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u /dev/null $TMP-stderr || exit 1
-diff -u - $TMP <<EOF || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare /dev/null $TMP-stderr || exit 1
+compare - $TMP <<EOF || exit 1
                # Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995,
                # 1996, 1997, 98, 1999, 2000, 2001, 2002, 2003, 2004,
                # 2005, 2006, 2007, 2008, 2009-2010 Free Software
@@ -298,14 +305,14 @@ Rem 2009 Free Software Foundation, Inc.@
 EOF
 UPDATE_COPYRIGHT_YEAR=2010 \
   update-copyright $TMP 1> $TMP-stdout 2> $TMP-stderr
-diff -u /dev/null $TMP-stdout || exit 1
-diff -u /dev/null $TMP-stderr || exit 1
+compare /dev/null $TMP-stdout || exit 1
+compare /dev/null $TMP-stderr || exit 1
 tr @ '\015' > $TMP-exp <<\EOF
 Rem Copyright (C) 87, 88, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 98,@
 Rem 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,@
 Rem 2009-2010 Free Software Foundation, Inc.@
 EOF
-diff -u $TMP-exp $TMP || exit 1
+compare $TMP-exp $TMP || exit 1
 rm $TMP*
 
 exit 0
-- 
1.5.4.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]