* srclist-update: Port to POSIX 1003.1-2001 hosts by avoiding the
[pspp] / config / srclist-update
index ef1bc2999281a878fbe3c55720fcd9b03ff478b6..cbe1af5292dcb78d340862cd83425bb1e2b4753b 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $Id: srclist-update,v 1.4 2002-11-25 13:17:17 meyering Exp $
+# $Id: srclist-update,v 1.6 2003-07-08 23:33:45 eggert Exp $
 #
 # Check for files in directory $1 being up to date, according to the
 # list on stdin.  Don't actually make any changes, just show the diffs.
@@ -13,8 +13,9 @@ fi
 verbose=false
 #chicken="echo (would)"
 
-srctmp=${TMPDIR-/tmp}/srclist.src
-dsttmp=${TMPDIR-/tmp}/srclist.dst
+: ${TMPDIR=/tmp}
+srctmp=$TMPDIR/srclist.src
+dsttmp=$TMPDIR/srclist.dst
 
 mydir=`dirname $0`
 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
@@ -50,22 +51,24 @@ fixlicense() \
 #
 fixfile() \
 {
-  if echo "$options" | grep -w gpl >/dev/null; then
-    fixlicense $1
-  else
-    cat $1
-  fi \
-  | fgrep -v '$'"Id:" >$2
+  case " $options " in
+  *' gpl '*)
+    fixlicense $1;;
+  *)
+    cat $1;;
+  esac \
+  | grep -v '\$Id: srclist-update,v 1.6 2003-07-08 23:33:45 eggert Exp $' >$2
 }
 
 
 # \f
 cat | while read src dst options; do
-  test -z "$dst" && continue  # skip lines without second element
-  echo "$src $dst" | sed 's/#.*$//' | egrep '^\s*$' >/dev/null \
-  && continue  # skip whitespace and comment-only lines
+  case $src:$dst in
+    *: ) continue;;  # skip lines without second element
+    '#'* ) continue;;  # skip comment-only lines
+  esac
 
-  src=`eval echo $src`
+  eval src=$src
   if test ! -r $src; then
     echo "$0: cannot read $src" >&2
     continue
@@ -74,7 +77,7 @@ cat | while read src dst options; do
   # Ignore subdirs in src dir.  E.g., if input spec is
   #   src/subdir/foo.c dst
   # write destination file dst/foo.c.
-  dst=`eval echo $dst`
+  eval dst=$dst
   test -d $dst && dst=$dst/`basename $src`
 
   # Make changes for sake of comparison.
@@ -93,7 +96,7 @@ cat | while read src dst options; do
     $verbose && echo "## $gplsrc $dst  # unchanged"
   else
     echo "## $gplsrc $dst  # changes"
-    diff -c2 $dst $gplsrc
+    diff -2 $dst $gplsrc
   fi
 done