#!/bin/bash
# Public domain (C) 2001 Martin Macok <martin.macok@underground.cz>

function DEBUG { echo "$@" ; }
#function DEBUG { }

if [ "$#" -lt "2" -o "x$1" == "x--help" ] ; then
	echo "Usage: $0 oldcategory newcategory"
	echo "Relearns statistics about message and store it in newcategory"
	echo "Message expected on stdin"
	exit 1
fi

OLDCAT="$1"
NEWCAT="$2"

if ! expr "x${OLDCAT}" : "x[-a-zA-Z0-9_@#]*$" >/dev/null ; then
	echo "ERR: Illegal characters in category name." >&2
	exit 1
fi

if ! expr "x${NEWCAT}" : "x[-a-zA-Z0-9_@#]*$" >/dev/null ; then
	echo "ERR: Illegal characters in category name." >&2
	exit 1
fi

# for ifile <1.0.3 substitute "-u" with "-i"
ifile -h -d "$OLDCAT" -u "$NEWCAT"
