Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-03-24 15:17:25 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2022-06-26 19:05:50 +0300
commit7d1c7d8337853ca99e6ec1150ac4b834cfed5cd3 (patch)
tree6fd6c647b5373ed376070d66ac6ca4acc507dee7 /shell
parent95fec31be601bfdced6bed7007a33b26e968e0db (diff)
ash,hush: use HOME for tab completion and prompts
ash and hush correctly use the value of HOME for tilde expansion. However the line editing code in libbb obtains the user's home directory by calling getpwuid(). Thus tildes in tab completion and prompts may be interpreted differently than in tilde expansion. When the line editing code is invoked from a shell make it use the shell's interpretation of tilde. This is similar to how GNU readline and bash collaborate. function old new delta get_homedir_or_NULL 29 72 +43 optschanged 119 126 +7 hush_main 1204 1211 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 57/0) Total: 57 bytes v2: Always check for HOME before trying the password database: this is what GNU readline does. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c7
-rw-r--r--shell/hush.c5
2 files changed, 5 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ef4a47afe..d29de37b7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -9720,7 +9720,7 @@ evalpipe(union node *n, int flags)
}
/* setinteractive needs this forward reference */
-#if EDITING_HAS_get_exe_name
+#if ENABLE_FEATURE_EDITING
static const char *get_builtin_name(int i) FAST_FUNC;
#endif
@@ -9757,9 +9757,8 @@ setinteractive(int on)
#if ENABLE_FEATURE_EDITING
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
+ line_input_state->sh_get_var = lookupvar;
}
#endif
}
@@ -10262,7 +10261,7 @@ find_builtin(const char *name)
return bp;
}
-#if EDITING_HAS_get_exe_name
+#if ENABLE_FEATURE_EDITING
static const char * FAST_FUNC
get_builtin_name(int i)
{
diff --git a/shell/hush.c b/shell/hush.c
index ae81f0da5..051b123e7 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 && EDITING_HAS_get_exe_name
+#if ENABLE_HUSH_JOB && ENABLE_FEATURE_EDITING
static const char * FAST_FUNC get_builtin_name(int i)
{
if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) {
@@ -10668,9 +10668,8 @@ 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
+ G.line_input_state->sh_get_var = get_local_var_value;
# endif
# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0
{