From 36f03e4c365890358c934485a6b590292127e2bc Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Sat, 4 Feb 2012 09:20:45 -0800 Subject: [PATCH] cnf: Inform the user of the missing command from the shell The shell missing command handler is the correct place to inform the user of the missing command, and not from the tool doing the replacement lookup. This also has the benefit that the message can exactly match what bash itself would have sent. It uses the actual interpreter name from $0 and the existing bash translations. Here's an example showing the handler vs bare bash: [dan@buster ~] su - Password: [root@buster ~]# LANG=de_DE [root@buster ~]# blah -bash: blah: Kommando nicht gefunden. [root@buster ~]# unset -f command_not_found_handle [root@buster ~]# blah -bash: blah: Kommando nicht gefunden. --- contrib/command-not-found/PackageKit.sh.in | 7 +++++-- contrib/command-not-found/pk-command-not-found.c | 5 ----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/contrib/command-not-found/PackageKit.sh.in b/contrib/command-not-found/PackageKit.sh.in index 5d2736f..bb39c8b 100644 --- a/contrib/command-not-found/PackageKit.sh.in +++ b/contrib/command-not-found/PackageKit.sh.in @@ -9,6 +9,11 @@ command_not_found_handle () { local runcnf=1 local retval=127 + local fmt + + # inform the user of the missing command + fmt=$(gettext bash "%s: command not found") + printf "%s: $fmt\n" "$0" "$1" # don't run if DBus isn't running [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0 @@ -20,8 +25,6 @@ command_not_found_handle () { if [ $runcnf -eq 1 ]; then @LIBEXECDIR@/pk-command-not-found "$@" retval=$? - else - echo "bash: $1: command not found" fi # return success or failure diff --git a/contrib/command-not-found/pk-command-not-found.c b/contrib/command-not-found/pk-command-not-found.c index ff5c64c..e1fea51 100644 --- a/contrib/command-not-found/pk-command-not-found.c +++ b/contrib/command-not-found/pk-command-not-found.c @@ -719,11 +719,6 @@ main (int argc, char *argv[]) if (len < 1) goto out; - /* TRANSLATORS: the prefix of all the output telling the user - * why it's not executing. NOTE: this is lowercase to mimic - * the style of bash itself -- apologies */ - g_printerr ("bash: %s: %s...\n", argv[1], _("command not found")); - /* user is not allowing CNF to do anything useful */ if (!config->software_source_search && !config->similar_name_search) -- 1.7.7.6