#!/bin/bash
# ISDK - Information System Development Kit
# Copyright (C) 1998-1999 Szilard Hajba, Peter Vazsonyi
#
# This program 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 program 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

FILE=ChangeLog

DIR=`pwd`
while [ -n "$DIR" -a ! -f "$DIR/$FILE" ]; do
    DIR=`echo $DIR |sed s+/[^/]*$++`
done

if [ -z "$DIR" ]; then
    echo "$0: file '$FILE' not found"
    exit 1
fi

if [ -z "$EDITOR" ]; then EDITOR=vim; fi
if [ -n "`echo $EDITOR | grep vim`" ]; then EDITOR="$EDITOR -c 3"; fi
echo -e "`date '+%Y-%m-%d %T'`    `cat ~/.ace.conf`\n\n\t* " >/tmp/.ace.tmp.$$
if [ -s $DIR/$FILE ]; then
    echo >>/tmp/.ace.tmp.$$
    cat $DIR/$FILE >> /tmp/.ace.tmp.$$
fi
touch /tmp/.ace.time.$$
$EDITOR /tmp/.ace.tmp.$$
if [ /tmp/.ace.tmp.$$ -nt /tmp/.ace.time.$$ ]; then
    mv /tmp/.ace.tmp.$$ $DIR/$FILE
fi
rm -f /tmp/.ace.*.$$
