From 1a4f18c9b5f5c4adeec9f349ded4d66b419feda6 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Sat, 4 Feb 2012 09:57:16 -0800 Subject: [PATCH] cnf: Ask the user before searching the package database Often the user has simply mistyped the command when the shell can't find it and would rather not wait while PackageKit roots around looking for the missing package. Ask the user to continue before searching the package database. This defaults to no and will assume no after a 5 second timeout. If the user doesn't want to be bothered, they can just hit return to get back to their prompt. --- contrib/command-not-found/PackageKit.sh.in | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/contrib/command-not-found/PackageKit.sh.in b/contrib/command-not-found/PackageKit.sh.in index 6960cf4..2974fdb 100644 --- a/contrib/command-not-found/PackageKit.sh.in +++ b/contrib/command-not-found/PackageKit.sh.in @@ -8,6 +8,7 @@ command_not_found_handle () { local fmt + local reply # inform the user of the missing command fmt=$(gettext bash "%s: command not found") @@ -22,6 +23,16 @@ command_not_found_handle () { # don't run if packagekitd doesn't exist in the _system_ root [ ! -x /usr/libexec/packagekitd ] && return 127 + # see if the user wants to check, but timeout after 5 seconds + read -p "Check for package to provide command '$1'? [N/y] " \ + -t 5 reply + + # output a newline if read timed out + [ $? -ne 0 ] && echo + + # don't run unless the user entered exactly y or yes + [ "$reply" = y -o "$reply" = yes ] || return 127 + # run the command @LIBEXECDIR@/pk-command-not-found "$@" } -- 1.7.7.6