From 27be0e8cfeb6f0f7a66bbfb2a6ca23d5a064e6ab Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 08:28:16 +0100 Subject: shell: fix compile failures in some configs Signed-off-by: Denys Vlasenko --- shell/ash.c | 8 ++++++-- shell/hush.c | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 326f8b2a9..99fdbce7b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9736,7 +9736,7 @@ evalpipe(union node *n, int flags) } /* setinteractive needs this forward reference */ -#if ENABLE_FEATURE_EDITING +#if ENABLE_FEATURE_TAB_COMPLETION static const char *get_builtin_name(int i) FAST_FUNC; #endif @@ -9773,8 +9773,12 @@ setinteractive(int on) #if ENABLE_FEATURE_EDITING if (!line_input_state) { line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP); +# if ENABLE_FEATURE_TAB_COMPLETION line_input_state->get_exe_name = get_builtin_name; +# endif +# if EDITING_HAS_sh_get_var line_input_state->sh_get_var = lookupvar; +# endif } #endif } @@ -10283,7 +10287,7 @@ find_builtin(const char *name) return bp; } -#if ENABLE_FEATURE_EDITING +#if ENABLE_FEATURE_TAB_COMPLETION static const char * FAST_FUNC get_builtin_name(int i) { diff --git a/shell/hush.c b/shell/hush.c index 051b123e7..693099209 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -8188,7 +8188,7 @@ static const struct built_in_command *find_builtin(const char *name) return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]); } -#if ENABLE_HUSH_JOB && ENABLE_FEATURE_EDITING +#if ENABLE_HUSH_JOB && ENABLE_FEATURE_TAB_COMPLETION static const char * FAST_FUNC get_builtin_name(int i) { if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { @@ -10668,8 +10668,12 @@ int hush_main(int argc, char **argv) # if ENABLE_FEATURE_EDITING G.line_input_state = new_line_input_t(FOR_SHELL); +# if ENABLE_FEATURE_TAB_COMPLETION G.line_input_state->get_exe_name = get_builtin_name; +# endif +# if EDITING_HAS_sh_get_var G.line_input_state->sh_get_var = get_local_var_value; +# endif # endif # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 { -- cgit v1.2.3-55-g6feb From d488a5218b378631ab78c3358dab9498426bc777 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 13:39:14 +0100 Subject: ash: trivial code shrink Signed-off-by: Denys Vlasenko --- shell/ash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 99fdbce7b..18ccc1329 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10018,7 +10018,7 @@ mklocal(char *name, int flags) setvareq(name, flags); else /* "local VAR" unsets VAR: */ - setvar0(name, NULL); + unsetvar(name); } } lvp->vp = vp; -- cgit v1.2.3-55-g6feb From 969e00816835769429fcd98046313f66b1c194fb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 3 Jan 2023 14:08:18 +0100 Subject: hush: code shrink function old new delta run_list 1032 1012 -20 Signed-off-by: Denys Vlasenko --- shell/hush.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'shell') diff --git a/shell/hush.c b/shell/hush.c index 693099209..d111f0cc5 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2460,10 +2460,15 @@ static int set_local_var(char *str, unsigned flags) return retval; } +static int set_local_var0(char *str) +{ + return set_local_var(str, 0); +} + static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val) { char *var = xasprintf("%s=%s", name, val); - set_local_var(var, /*flag:*/ 0); + set_local_var0(var); } /* Used at startup and after each cd */ @@ -6964,7 +6969,7 @@ static NOINLINE int expand_one_var(o_string *output, int n, val = NULL; } else { char *new_var = xasprintf("%s=%s", var, val); - set_local_var(new_var, /*flag:*/ 0); + set_local_var0(new_var); } } } @@ -9373,7 +9378,7 @@ static NOINLINE int run_pipe(struct pipe *pi) } #endif debug_printf_env("set shell var:'%s'->'%s'\n", *argv, p); - if (set_local_var(p, /*flag:*/ 0)) { + if (set_local_var0(p)) { /* assignment to readonly var / putenv error? */ rcode = 1; } @@ -9856,7 +9861,7 @@ static int run_list(struct pipe *pi) } /* Insert next value from for_lcur */ /* note: *for_lcur already has quotes removed, $var expanded, etc */ - set_local_var(xasprintf("%s=%s", pi->cmds[0].argv[0], *for_lcur++), /*flag:*/ 0); + set_local_var_from_halves(pi->cmds[0].argv[0], *for_lcur++); continue; } if (rword == RES_IN) { -- cgit v1.2.3-55-g6feb