diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-01-03 08:28:16 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-01-03 08:28:16 +0100 |
commit | 27be0e8cfeb6f0f7a66bbfb2a6ca23d5a064e6ab (patch) | |
tree | bf56f6d0d922cf3eefb0e413e9326a2e60373dd8 | |
parent | 8ed57db65ba66709d3b4061c4f03766f1fe58780 (diff) | |
download | busybox-w32-27be0e8cfeb6f0f7a66bbfb2a6ca23d5a064e6ab.tar.gz busybox-w32-27be0e8cfeb6f0f7a66bbfb2a6ca23d5a064e6ab.tar.bz2 busybox-w32-27be0e8cfeb6f0f7a66bbfb2a6ca23d5a064e6ab.zip |
shell: fix compile failures in some configs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 8 | ||||
-rw-r--r-- | libbb/lineedit.c | 24 | ||||
-rw-r--r-- | shell/ash.c | 8 | ||||
-rw-r--r-- | shell/hush.c | 6 |
4 files changed, 31 insertions, 15 deletions
diff --git a/include/libbb.h b/include/libbb.h index 19ed9ec09..cca33a177 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1939,9 +1939,15 @@ typedef struct line_input_t { | |||
1939 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH | 1939 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH |
1940 | /* function to fetch additional application-specific names to match */ | 1940 | /* function to fetch additional application-specific names to match */ |
1941 | get_exe_name_t *get_exe_name; | 1941 | get_exe_name_t *get_exe_name; |
1942 | # endif | ||
1943 | # endif | ||
1944 | # if (ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT) \ | ||
1945 | && (ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH) | ||
1942 | /* function to fetch value of shell variable */ | 1946 | /* function to fetch value of shell variable */ |
1943 | sh_get_var_t *sh_get_var; | 1947 | sh_get_var_t *sh_get_var; |
1944 | # endif | 1948 | # define EDITING_HAS_sh_get_var 1 |
1949 | # else | ||
1950 | # define EDITING_HAS_sh_get_var 0 | ||
1945 | # endif | 1951 | # endif |
1946 | # if MAX_HISTORY | 1952 | # if MAX_HISTORY |
1947 | int cnt_history; | 1953 | int cnt_history; |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 697f2a577..d6b2e76ff 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -249,14 +249,6 @@ static void get_user_strings(void) | |||
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | static const char *get_username_str(void) | ||
253 | { | ||
254 | if (!got_user_strings) | ||
255 | get_user_strings(); | ||
256 | return user_buf ? user_buf : ""; | ||
257 | /* btw, bash uses "I have no name!" string if uid has no entry */ | ||
258 | } | ||
259 | |||
260 | static NOINLINE const char *get_homedir_or_NULL(void) | 252 | static NOINLINE const char *get_homedir_or_NULL(void) |
261 | { | 253 | { |
262 | const char *home; | 254 | const char *home; |
@@ -275,6 +267,16 @@ static NOINLINE const char *get_homedir_or_NULL(void) | |||
275 | } | 267 | } |
276 | #endif | 268 | #endif |
277 | 269 | ||
270 | #if ENABLE_FEATURE_EDITING_FANCY_PROMPT | ||
271 | static const char *get_username_str(void) | ||
272 | { | ||
273 | if (!got_user_strings) | ||
274 | get_user_strings(); | ||
275 | return user_buf ? user_buf : ""; | ||
276 | /* btw, bash uses "I have no name!" string if uid has no entry */ | ||
277 | } | ||
278 | #endif | ||
279 | |||
278 | #if ENABLE_UNICODE_SUPPORT | 280 | #if ENABLE_UNICODE_SUPPORT |
279 | static size_t load_string(const char *src) | 281 | static size_t load_string(const char *src) |
280 | { | 282 | { |
@@ -2035,13 +2037,13 @@ static void parse_and_put_prompt(const char *prmt_ptr) | |||
2035 | case 'W': /* basename of cur dir */ | 2037 | case 'W': /* basename of cur dir */ |
2036 | if (!cwd_buf) { | 2038 | if (!cwd_buf) { |
2037 | const char *home; | 2039 | const char *home; |
2038 | #if ENABLE_SHELL_ASH | 2040 | # if EDITING_HAS_sh_get_var |
2039 | cwd_buf = state->sh_get_var | 2041 | cwd_buf = state->sh_get_var |
2040 | ? xstrdup(state->sh_get_var("PWD")) | 2042 | ? xstrdup(state->sh_get_var("PWD")) |
2041 | : xrealloc_getcwd_or_warn(NULL); | 2043 | : xrealloc_getcwd_or_warn(NULL); |
2042 | #else | 2044 | # else |
2043 | cwd_buf = xrealloc_getcwd_or_warn(NULL); | 2045 | cwd_buf = xrealloc_getcwd_or_warn(NULL); |
2044 | #endif | 2046 | # endif |
2045 | if (!cwd_buf) | 2047 | if (!cwd_buf) |
2046 | cwd_buf = (char *)bb_msg_unknown; | 2048 | cwd_buf = (char *)bb_msg_unknown; |
2047 | else if ((home = get_homedir_or_NULL()) != NULL && home[0]) { | 2049 | else if ((home = get_homedir_or_NULL()) != NULL && home[0]) { |
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) | |||
9736 | } | 9736 | } |
9737 | 9737 | ||
9738 | /* setinteractive needs this forward reference */ | 9738 | /* setinteractive needs this forward reference */ |
9739 | #if ENABLE_FEATURE_EDITING | 9739 | #if ENABLE_FEATURE_TAB_COMPLETION |
9740 | static const char *get_builtin_name(int i) FAST_FUNC; | 9740 | static const char *get_builtin_name(int i) FAST_FUNC; |
9741 | #endif | 9741 | #endif |
9742 | 9742 | ||
@@ -9773,8 +9773,12 @@ setinteractive(int on) | |||
9773 | #if ENABLE_FEATURE_EDITING | 9773 | #if ENABLE_FEATURE_EDITING |
9774 | if (!line_input_state) { | 9774 | if (!line_input_state) { |
9775 | line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP); | 9775 | line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP); |
9776 | # if ENABLE_FEATURE_TAB_COMPLETION | ||
9776 | line_input_state->get_exe_name = get_builtin_name; | 9777 | line_input_state->get_exe_name = get_builtin_name; |
9778 | # endif | ||
9779 | # if EDITING_HAS_sh_get_var | ||
9777 | line_input_state->sh_get_var = lookupvar; | 9780 | line_input_state->sh_get_var = lookupvar; |
9781 | # endif | ||
9778 | } | 9782 | } |
9779 | #endif | 9783 | #endif |
9780 | } | 9784 | } |
@@ -10283,7 +10287,7 @@ find_builtin(const char *name) | |||
10283 | return bp; | 10287 | return bp; |
10284 | } | 10288 | } |
10285 | 10289 | ||
10286 | #if ENABLE_FEATURE_EDITING | 10290 | #if ENABLE_FEATURE_TAB_COMPLETION |
10287 | static const char * FAST_FUNC | 10291 | static const char * FAST_FUNC |
10288 | get_builtin_name(int i) | 10292 | get_builtin_name(int i) |
10289 | { | 10293 | { |
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) | |||
8188 | return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]); | 8188 | return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]); |
8189 | } | 8189 | } |
8190 | 8190 | ||
8191 | #if ENABLE_HUSH_JOB && ENABLE_FEATURE_EDITING | 8191 | #if ENABLE_HUSH_JOB && ENABLE_FEATURE_TAB_COMPLETION |
8192 | static const char * FAST_FUNC get_builtin_name(int i) | 8192 | static const char * FAST_FUNC get_builtin_name(int i) |
8193 | { | 8193 | { |
8194 | if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { | 8194 | if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { |
@@ -10668,8 +10668,12 @@ int hush_main(int argc, char **argv) | |||
10668 | 10668 | ||
10669 | # if ENABLE_FEATURE_EDITING | 10669 | # if ENABLE_FEATURE_EDITING |
10670 | G.line_input_state = new_line_input_t(FOR_SHELL); | 10670 | G.line_input_state = new_line_input_t(FOR_SHELL); |
10671 | # if ENABLE_FEATURE_TAB_COMPLETION | ||
10671 | G.line_input_state->get_exe_name = get_builtin_name; | 10672 | G.line_input_state->get_exe_name = get_builtin_name; |
10673 | # endif | ||
10674 | # if EDITING_HAS_sh_get_var | ||
10672 | G.line_input_state->sh_get_var = get_local_var_value; | 10675 | G.line_input_state->sh_get_var = get_local_var_value; |
10676 | # endif | ||
10673 | # endif | 10677 | # endif |
10674 | # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 | 10678 | # if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 |
10675 | { | 10679 | { |