set -e
DICTIONARY_FILE=${1}
PATTERN_FILE=${2}
PATOUT_FILE=${3}
TRANSLATE_FILE=${4}
LEFT_HYPHEN_MIN=${5}
LEFT_HYPHEN_MAX=${6}
HYPH_LEVEL=${7}
PAT_START=${8}
PAT_FINISH=${9}
GOOD_WEIGHT=${10}
BAD_WEIGHT=${11}
THRESHOLD=${12}
FIFO=tmp
rm -f $FIFO
mkfifo $FIFO
if which gtimeout >/dev/null; then
    TIMEOUT=gtimeout;
else
    TIMEOUT=timeout
fi
$TIMEOUT 3 patgen $DICTIONARY_FILE $PATTERN_FILE $PATOUT_FILE $TRANSLATE_FILE <$FIFO &
echo $LEFT_HYPHEN_MIN $LEFT_HYPHEN_MAX >$FIFO
echo $HYPH_LEVEL $HYPH_LEVEL >$FIFO
echo $PAT_START $PAT_FINISH >$FIFO
echo $GOOD_WEIGHT $BAD_WEIGHT $THRESHOLD >$FIFO
echo y >$FIFO
wait $!
ret=$?
rm -f $FIFO
if [ $ret == 0 ]; then
    touch $PATOUT_FILE pattmp.$HYPH_LEVEL
else
    rm -f $PATOUT_FILE pattmp.$HYPH_LEVEL
fi
exit $ret

set -e
DICTIONARY_FILE=${1}
PATTERN_FILE=${2}
PATOUT_FILE=${3}
TRANSLATE_FILE=${4}
LEFT_HYPHEN_MIN=${5}
LEFT_HYPHEN_MAX=${6}
HYPH_LEVEL=${7}
PAT_START=${8}
PAT_FINISH=${9}
GOOD_WEIGHT=${10}
BAD_WEIGHT=${11}
THRESHOLD=${12}
FIFO=tmp
rm -f $FIFO
mkfifo $FIFO
patgen $DICTIONARY_FILE $PATTERN_FILE $PATOUT_FILE $TRANSLATE_FILE <$FIFO &
echo $LEFT_HYPHEN_MIN $LEFT_HYPHEN_MAX >$FIFO
echo $HYPH_LEVEL $HYPH_LEVEL >$FIFO
echo $PAT_START $PAT_FINISH >$FIFO
echo $GOOD_WEIGHT $BAD_WEIGHT $THRESHOLD >$FIFO
echo y >$FIFO
wait $!
ret=$?
rm -f $FIFO
if [ $ret == 0 ]; then
    touch $PATOUT_FILE pattmp.$HYPH_LEVEL
else
    rm -f $PATOUT_FILE pattmp.$HYPH_LEVEL
fi
exit $ret

Remove the use of timeout
Remove the use of timeout

It seems to work perfectly without.
