#!/bin/sh

NKF='/usr/bin/nkf -s -m0'

MSGFILE="$1"
TMPFILE="$1".ttssh2.tmp.$$

if [ $# -eq 0 ]; then
	exit 0
fi

if [ -e "${TMPFILE}" ]; then
	echo "${TMPFILE} is already exists."
	echo "Kanji-code conversion is disabled."
	exit 0
fi

if $NKF "${MSGFILE}" > "${TMPFILE}"; then
	mv "${TMPFILE}" "${MSGFILE}"
else
	echo "nkf failed."
	echo "Kanji-code conversion is disabled."
	rm -f "${TMPFILE}"
fi

exit 0
