command_not_found_handle() {

    local cmd state rest
    local -i pid ppid pgrp session tty_nr tpgid

    # do not run when inside Midnight Commander or within a Pipe
    if test -n "$MC_SID" -o ! -t 1 ; then
        return 127
    fi

    # do not run when within a subshell
    read pid cmd state ppid pgrp session tty_nr tpgid rest  < /proc/self/stat
    if test $$ -eq $tpgid ; then
        return 127
    fi

    # test for /usr/sbin and /sbin
    if test -x "/usr/sbin/$1" -o -x "/sbin/$1" ; then
        if test -x "/usr/sbin/$1" ; then prefix='/usr' ; else prefix='' ; fi
        echo "Absolute path to '$1' is '$prefix/sbin/$1', so it might be intended to be run only by user with superuser privileges (eg. root)."
        return 127
    fi

    if test -n "$COMMAND_NOT_FOUND_AUTO" ; then
        # call command-not-found directly
        test -x /usr/bin/python && test -x /usr/bin/command-not-found && /usr/bin/python /usr/bin/command-not-found "$1" zypp
    else
        # print only info about command-not-found
        echo -e "If '$1' is not a typo you can run the following command to lookup the package that contains the binary:\n    command-not-found $1"
    fi

    return 127
}
