#!/bin/sh
tmp=/tmp/add_meta_tag$$

charset="$1"
shift

cleanup()
{
        rm -f $tmp
	exit $1
}


trap cleanup 1 2 3 4 5 6 7 8 9 10 12 13 14 15

for file in "$@"
do
        echo "$file"
	cp "$file" "$tmp"
	sed 's|</HEAD|<meta http-equiv="Content-Type" content="text/html; charset='$charset'"></HEAD|'\
        	< "$tmp" > "$file"
done

cleanup 0
