diff options
author | Ron Yorston <rmy@pobox.com> | 2022-03-24 11:43:37 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-03-24 12:26:01 +0000 |
commit | 3e385d22cc57aacddafe38a1b6bcd55aa71d3c80 (patch) | |
tree | 8c8ac54290ec6010d76206c5bd0e47f92bf2b13f /include | |
parent | af41de68901d48753eb73491d54931a99d1a13b5 (diff) | |
download | busybox-w32-tilde.tar.gz busybox-w32-tilde.tar.bz2 busybox-w32-tilde.zip |
ash,hush: use HOME for tab completion and promptstilde
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/include/libbb.h b/include/libbb.h index 740c25528..1c9198945 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1984,6 +1984,7 @@ unsigned size_from_HISTFILESIZE(const char *hp) FAST_FUNC; | |||
1984 | # define MAX_HISTORY 0 | 1984 | # define MAX_HISTORY 0 |
1985 | # endif | 1985 | # endif |
1986 | typedef const char *get_exe_name_t(int i) FAST_FUNC; | 1986 | typedef const char *get_exe_name_t(int i) FAST_FUNC; |
1987 | typedef const char *sh_get_var_t(const char *name) FAST_FUNC; | ||
1987 | typedef struct line_input_t { | 1988 | typedef struct line_input_t { |
1988 | int flags; | 1989 | int flags; |
1989 | int timeout; | 1990 | int timeout; |
@@ -1997,9 +1998,8 @@ typedef struct line_input_t { | |||
1997 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH | 1998 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH |
1998 | /* function to fetch additional application-specific names to match */ | 1999 | /* function to fetch additional application-specific names to match */ |
1999 | get_exe_name_t *get_exe_name; | 2000 | get_exe_name_t *get_exe_name; |
2000 | # define EDITING_HAS_get_exe_name 1 | 2001 | /* function to fetch value of shell variable */ |
2001 | # else | 2002 | sh_get_var_t *sh_get_var; |
2002 | # define EDITING_HAS_get_exe_name 0 | ||
2003 | # endif | 2003 | # endif |
2004 | # endif | 2004 | # endif |
2005 | # if MAX_HISTORY | 2005 | # if MAX_HISTORY |
@@ -2053,11 +2053,6 @@ int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC; | |||
2053 | read_line_input(prompt, command, maxsize) | 2053 | read_line_input(prompt, command, maxsize) |
2054 | #endif | 2054 | #endif |
2055 | 2055 | ||
2056 | #ifndef EDITING_HAS_get_exe_name | ||
2057 | # define EDITING_HAS_get_exe_name 0 | ||
2058 | #endif | ||
2059 | |||
2060 | |||
2061 | #ifndef COMM_LEN | 2056 | #ifndef COMM_LEN |
2062 | # ifdef TASK_COMM_LEN | 2057 | # ifdef TASK_COMM_LEN |
2063 | enum { COMM_LEN = TASK_COMM_LEN }; | 2058 | enum { COMM_LEN = TASK_COMM_LEN }; |