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 14:27:19 -0900
User-agent: Mutt/1.5.20 (2009-06-14)

On Tue, Dec 29, 2009 at 12:33:25PM -0900, Ken Irving wrote:
> 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:

Ok, one last go at this, losing some local variables.  

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

-- 
Ken.Irving@alaska.edu




reply via email to

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