[Top][All Lists]

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

command_not_found_handle not called if "command" includes a slash

From: Ken Irving
Subject: command_not_found_handle not called if "command" includes a slash
Date: Sat, 26 Dec 2009 12:54:47 -0900

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux hayes 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 
Machine Type: i486-pc-linux-gnu

Bash Version: 4.0
Patch Level: 33
Release Status: release

    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.
    The behavior is not new; a second example is included below from v3.2,
    showing the same error message when the bad command looks like a path.

    I'd like to dig into this, to see if there's any hope of hooking into
    this case in order to provide a handler, but have no idea where to look.
    Is there any hope for this?

    $ export PS1='\$?=$?\n$ '
    $ kj
    -bash: kj: command not found
    $ ./kjdf
    -bash: ./kjdf: No such file or directory
    $ command_not_found_handle() { cmd="$1"; exec echo "$cmd" "$@"; }
    $ kj a b c
    kj kj a b c
    $ ./kj a b c
    -bash: ./kj: No such file or directory
    $ bash --version
    GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu)
    Copyright (C) 2009 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later 
    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

An example on v3.2:

    $ export PS1='\$?=$?\n$ '
    $ bash --version
    GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
    Copyright (C) 2007 Free Software Foundation, Inc.
    $ kj
    bash: kj: command not found
    $ ./kj
    bash: ./kj: No such file or directory


reply via email to

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