Resolves: #432579. Added check for "command_not_found_handler" shell

function.
This commit is contained in:
Roman Rakus 2008-12-04 15:19:43 +00:00
parent 0314d4fed5
commit e96c4c2deb
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,49 @@
diff -up bash-3.2/config-top.h.command_not_found bash-3.2/config-top.h
--- bash-3.2/config-top.h.command_not_found 2008-12-04 15:45:21.000000000 +0100
+++ bash-3.2/config-top.h 2008-12-04 15:45:55.000000000 +0100
@@ -87,3 +87,7 @@
/* Define this if you want bash to try to check whether it's being run by
sshd and source the .bashrc if so (like the rshd behavior). */
#define SSH_SOURCE_BASHRC
+
+/* Define this if you want bash to try to find command_not_found_handler
+ shell function */
+#define COMMAND_NOT_FOUND_HANDLER
diff -up bash-3.2/execute_cmd.c.command_not_found bash-3.2/execute_cmd.c
--- bash-3.2/execute_cmd.c.command_not_found 2008-12-04 15:34:48.000000000 +0100
+++ bash-3.2/execute_cmd.c 2008-12-04 15:34:52.000000000 +0100
@@ -3737,10 +3737,33 @@ execute_disk_command (words, redirects,
if (command == 0)
{
+#if defined (COMMAND_NOT_FOUND_HANDLER)
+ SHELL_VAR *f, *v;
+ WORD_LIST *cmdlist;
+ WORD_DESC *w;
+ int fval;
+ if ( (posixly_correct || interactive_shell == 0) ||
+ ( f = find_function ("command_not_found_handler")) == 0)
+ {
+ internal_error (_("%s: command not found"), pathname);
+ exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */
+ }
+ w = make_word("command_not_found_handler");
+ cmdlist = make_word_list(w, (WORD_LIST*)NULL);
+
+ w = make_word(pathname);
+ cmdlist->next = make_word_list(w, (WORD_LIST*)NULL);
+
+ fval = execute_shell_function (f, cmdlist);
+ if (fval == EX_NOTFOUND)
+ internal_error (_("%s: command not found"), pathname);
+ exit(fval);
+ }
+#else
internal_error (_("%s: command not found"), pathname);
exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */
}
-
+#endif
/* Execve expects the command name to be in args[0]. So we
leave it there, in the same format that the user used to
type it in. */

View File

@ -1,7 +1,7 @@
Version: 3.2
Name: bash
Summary: The GNU Bourne Again shell (bash) version %{version}
Release: 29%{?dist}
Release: 30%{?dist}
Group: System Environment/Shells
License: GPLv2+
Url: http://www.gnu.org/software/bash
@ -76,6 +76,7 @@ Patch140: bash-3.2-man-page-suspend.patch
Patch141: bash-3.2-patch035.patch
Patch142: bash-3.2-execve_catch_signals.patch
Patch143: bash-3.2-ssh_source_bash.patch
Patch144: bash-3.2-command_not_found.patch
Requires(post): ncurses-libs
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -163,6 +164,7 @@ compliance over previous versions.
%patch140 -p1 -b .man-page-suspend
%patch142 -p1 -b .execve_catch_signals
%patch143 -p1 -b .ssh_source_bash
%patch144 -p1 -b .command_not_found
echo %{version} > _distribution
echo %{release} > _patchlevel
@ -304,6 +306,10 @@ fi
%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog
* Thu Dec 04 2008 Roman Rakus <rrakus@redhat.com> - 3.2-30
- Added check for `command_not_found_handler' shell function
Resolves: #432579
* Tue Oct 28 2008 Jesse Keating <jkeating@redhat.com> - 3.2-29
- Add the Requires(post) back for ncurses-libs, so that rpm knows
where to break the loop. The post actually does require the curses