From 0a880d7d134e0023a1534804859cb8b277deda58 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Sat, 4 Feb 2012 09:34:31 -0800 Subject: [PATCH] cnf: Only search for packages when shell is interactive If we're inside a script, we can't ask a user to install a package, so just return with an error. Example: $ banshee -bash: banshee: command not found Install package 'banshee' to provide command 'banshee'? [N/y] $ bash -c '. /etc/profile.d/PackageKit.sh; banshee' bash: banshee: command not found --- contrib/command-not-found/PackageKit.sh.in | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/contrib/command-not-found/PackageKit.sh.in b/contrib/command-not-found/PackageKit.sh.in index bb39c8b..3097a39 100644 --- a/contrib/command-not-found/PackageKit.sh.in +++ b/contrib/command-not-found/PackageKit.sh.in @@ -15,6 +15,9 @@ command_not_found_handle () { fmt=$(gettext bash "%s: command not found") printf "%s: $fmt\n" "$0" "$1" + # only search for the command if we're interactive + [[ $- =~ i ]] || runcnf=0 + # don't run if DBus isn't running [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0 -- 1.7.7.6