#!/bin/sh
#+++
#  RCS mergeacttimes.sh,v 1.2 1995/07/13 11:37:04 tom Exp
#  title:	mergeacctimes.sh
#  abstract:	Merge active and active.times to produce updated active.times.
#  author:	T.R.Hageman, Groningen, The Netherlands
#  created:	December 1994
#  modified:	(see RCS Log at end)
#  copyright:
#
#		Copyright (C) 1994,1995  Tom R. Hageman.
#
#	This is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2 of the License, or
#	(at your option) any later version.
#
#	This software is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this software; if not, write to the Free Software
#	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#  description:
#---
if [ $# != 2 ]
then
	echo "Usage: $0 active active.times" >&2
	exit 2
fi

now=0
me=${LOGNAME-${USER-unknown}}

# =()<: ${NEWSCONFIG=@<NEWSCONFIG>@}>()=
: ${NEWSCONFIG=/usr/local/lib/news/bin/config}
[ -r ${NEWSCONFIG} ] && {
	. ${NEWSCONFIG}
	export NEWSCTL NEWSBIN NEWSARTS NEWSPATH NEWSUMASK NEWSMASTER NEWSCONFIG
	PATH=$NEWSBIN:$NEWSPATH
	export PATH

	now=`now 2>/dev/null`
	case "$now" in "") now=0; esac 
	me=$me@`newshostname`
}

awk '
FILENAME != Filename { NFiles++; Filename = FILENAME }

NFiles == 1 {
	groups[$1] = 1
	next
}

{
	groups[$1] = 0
	print
}

END {
	for (g in groups) {
		if (groups[g]) print g " '"$now"' '"$me"'";
	}
}
' "$@" | sort
