#! /bin/sh
# -*- mode: sh; coding: utf-8 -*-
#
# tla-last-modified
#
# tla-last-modified extracts the last modification date of a given
# file from a ChangeLog generated by tla.
#
# Copyright (C) 2003 Elmar Hoffmann
#

set -e

if [ $# -ne 1 ]; then
    echo "Usage: $(basename $0) FILE"
    exit 1
fi

# escape file name
file=`echo $1 | sed 's,\(\.\|\+\),\\\\\1,g'`

sed -n "
# copy date to hold space
s/^\([0-9]\+-[0-9]\+-[0-9]\+ [0-9]\+:[0-9]\+:[0-9]\+ GMT\)\t.*\$/\1/
T nodate
h
b next
: nodate

# check if file is in list of modified files
/^ *\(new\|modified\) files:$/b files
b next
: files
n
/$file/b print
b next

# print date from hold space
: print
g
p
q
: next
" ChangeLog
