k
    done
}

# [t]ry again, [r]econfigure, [a] abort
tra()
{
    msg=$1
    cls
    echo "Oops, I am in trouble here! The error was:"
    echo ">> $msg <<"
    echo
    case `getopt TRQ 'What shall we do now: <t>ry again, <r>econfigure, <q>uit'` in
        T) return;;
        R) menu_main;;
        Q) exit 1;;
    esac
}

warn()
{
    msg=$1
    cls
    echo "Oops, I am in trouble here! The problem was:"
    echo ">> $msg <<"
    echo
    case `getopt CQ 'What shall we do now: <c>continue, <q>uit'` in
        C) return;;
        Q) exit 1;;
    esac
}

fatal()
{
    echo; echo
    echo "ERROR: $@."
    echo "This was a fatal error, my friend. Installation aborted."
    exit 1
}

show_error()
{
    test $? = 0 && return
    cls
    echo 'WARNING: the last command returned an error.'
    if yesno 'Do you want to see the errorlog'; then
        cat $ERRLOG | $PAGER
        readln
    fi
    cls
}

# this is a hard job... trying to anticipiate trouble...
sanity_checks()
{
    while test -d $TMPDIR; do
        tra "temporal directory $TMPDIR already exists"
    done
    while test -d $TETEXDIR; do
        tra "directory TETEXDIR=$TETEXDIR already exists"
    done
    while test -d $TEXMF; do
        tra "directory TEXMF=$TEXMF already exists"
    done
    while test "$opt_symlink" = X &&
          test ! -z "$opt_symlinks_bin" &&
          test -d "$opt_symlinks_bin" &&
          test ! -w "$opt_symlinks_bin"; do
        tra "cannot write to dire