bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: command_not_found_handle not called if "command" includes a slash


From: Ken Irving
Subject: Re: command_not_found_handle not called if "command" includes a slash
Date: Tue, 29 Dec 2009 12:33:25 -0900
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Dec 28, 2009 at 03:24:33PM -0900, Ken Irving wrote:
> On Sat, Dec 26, 2009 at 12:54:47PM -0900, Ken Irving wrote:
> > Description:
> >     I'm not sure this is a bug, but I notice that the
> >     command_not_found_handle function is not called if the "command" has a
> >     slash in it.  I can't find anywhere in the bash source producing the
> >     "No such file ..."  error message, so I guess this is being caught
> >     somewhere else before bash gets the command line to process.
> 
> Fix:
> 
>     This patch is not sufficient, as it leaves the error message, but it
>     does call the hook function in the problem cases:

This patch is better, calling the hook function before the error message
is produced:

$ diff -u execute_cmd.c{-original,}
--- execute_cmd.c-original      2009-12-28 14:48:46.000000000 -0900
+++ execute_cmd.c       2009-12-29 12:20:05.000000000 -0900
@@ -4660,6 +4660,8 @@
   int larray, i, fd;
   char sample[80];
   int sample_len;
+  SHELL_VAR *hookf;
+  WORD_LIST *wl, *words;
 
   SETOSTYPE (0);               /* Some systems use for USG/POSIX semantics */
   execve (command, args, env);
@@ -4675,6 +4677,13 @@
        internal_error (_("%s: is a directory"), command);
       else if (executable_file (command) == 0)
        {
+         hookf = find_function (NOTFOUND_HOOK);
+         if (hookf != 0)
+           {
+             words = strvec_to_word_list (args, 0, 0);
+             wl = make_word_list (make_word (NOTFOUND_HOOK), words);
+             exit (execute_shell_function (hookf, wl));
+           }
          errno = i;
          file_error (command);
        }

-- 
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]