diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 19 | ||||
-rw-r--r-- | shell/hush.c | 17 |
2 files changed, 35 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index d6040f47e..fb4028219 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9523,6 +9523,11 @@ evalpipe(union node *n, int flags) return status; } +/* setinteractive needs this forward reference */ +#if EDITING_HAS_get_exe_name +static const char *get_builtin_name(int i) FAST_FUNC; +#endif + /* * Controls whether the shell is interactive or not. */ @@ -9554,8 +9559,12 @@ setinteractive(int on) } #endif #if ENABLE_FEATURE_EDITING - if (!line_input_state) + if (!line_input_state) { line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP); +# if EDITING_HAS_get_exe_name + line_input_state->get_exe_name = get_builtin_name; +# endif + } #endif } } @@ -10023,6 +10032,14 @@ find_builtin(const char *name) return bp; } +#if EDITING_HAS_get_exe_name +static const char * FAST_FUNC +get_builtin_name(int i) +{ + return /*i >= 0 &&*/ i < ARRAY_SIZE(builtintab) ? builtintab[i].name + 1 : NULL; +} +#endif + /* * Execute a simple command. */ diff --git a/shell/hush.c b/shell/hush.c index 97202b953..6e44d4e11 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -7889,6 +7889,20 @@ static const struct built_in_command *find_builtin(const char *name) return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]); } +#if EDITING_HAS_get_exe_name +static const char * FAST_FUNC get_builtin_name(int i) +{ + if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { + return bltins1[i].b_cmd; + } + i -= ARRAY_SIZE(bltins1); + if (i < ARRAY_SIZE(bltins2)) { + return bltins2[i].b_cmd; + } + return NULL; +} +#endif + static void remove_nested_vars(void) { struct variable *cur; @@ -10268,6 +10282,9 @@ int hush_main(int argc, char **argv) # if ENABLE_FEATURE_EDITING G.line_input_state = new_line_input_t(FOR_SHELL); +# if EDITING_HAS_get_exe_name + G.line_input_state->get_exe_name = get_builtin_name; +# endif # endif # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 { |