diff options
-rw-r--r-- | shell/ash.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index 8211c766f..865159d20 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -51,6 +51,15 @@ | |||
51 | //config: default y | 51 | //config: default y |
52 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH | 52 | //config: depends on ASH || SH_IS_ASH || BASH_IS_ASH |
53 | //config: | 53 | //config: |
54 | //config:config ASH_BASH_NOT_FOUND_HOOK | ||
55 | //config: bool "command_not_found_handle hook support" | ||
56 | //config: default y | ||
57 | //config: depends ASH_BASH_COMPAT | ||
58 | //config: help | ||
59 | //config: Enable support for the 'command_not_found_handle' hook function, | ||
60 | //config: from GNU bash, which allows for alternative command not found | ||
61 | //config: handling. | ||
62 | //config: | ||
54 | //config:config ASH_JOB_CONTROL | 63 | //config:config ASH_JOB_CONTROL |
55 | //config: bool "Job control" | 64 | //config: bool "Job control" |
56 | //config: default y | 65 | //config: default y |
@@ -13227,8 +13236,21 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
13227 | /* We failed. If there was an entry for this command, delete it */ | 13236 | /* We failed. If there was an entry for this command, delete it */ |
13228 | if (cmdp && updatetbl) | 13237 | if (cmdp && updatetbl) |
13229 | delete_cmd_entry(); | 13238 | delete_cmd_entry(); |
13230 | if (act & DO_ERR) | 13239 | if (act & DO_ERR) { |
13240 | #if ENABLE_ASH_BASH_NOT_FOUND_HOOK | ||
13241 | struct tblentry *hookp = cmdlookup("command_not_found_handle", 0); | ||
13242 | if (hookp && hookp->cmdtype == CMDFUNCTION) { | ||
13243 | char *argv[3]; | ||
13244 | argv[0] = (char*) "command_not_found_handle"; | ||
13245 | argv[1] = name; | ||
13246 | argv[2] = NULL; | ||
13247 | evalfun(hookp->param.func, 2, argv, 0); | ||
13248 | entry->cmdtype = CMDUNKNOWN; | ||
13249 | return; | ||
13250 | } | ||
13251 | #endif | ||
13231 | ash_msg("%s: %s", name, errmsg(e, "not found")); | 13252 | ash_msg("%s: %s", name, errmsg(e, "not found")); |
13253 | } | ||
13232 | entry->cmdtype = CMDUNKNOWN; | 13254 | entry->cmdtype = CMDUNKNOWN; |
13233 | return; | 13255 | return; |
13234 | 13256 | ||