lineedit: disable completion and fancy prompts if no shells are selected
function old new delta
get_previous_history 51 56 +5
get_next_history 47 52 +5
null_str 1 - -1
beep 10 - -10
bb_msg_unknown 10 - -10
bb_internal_setpwent 24 - -24
remove_chunk 30 - -30
goto_new_line 33 - -33
bb_internal_endpwent 36 - -36
deinit_S 51 - -51
free_tab_completion_data 54 - -54
read_line_input 3171 3114 -57
rewind 68 - -68
add_match 70 - -70
complete_username 77 - -77
quote_special_chars 78 - -78
build_match_prefix 557 - -557
complete_cmd_dir_file 697 - -697
parse_and_put_prompt 823 53 -770
input_tab 926 - -926
------------------------------------------------------------------------------
(add/remove: 0/17 grow/shrink: 2/2 up/down: 10/-3549) Total: -3539 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 0c48e81..c3b5738 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -57,12 +57,23 @@
#if ENABLE_FEATURE_EDITING
+#if !ENABLE_SHELL_ASH && !ENABLE_SHELL_HUSH
+/* so far only shells use these features */
+# undef ENABLE_FEATURE_EDITING_FANCY_PROMPT
+# undef ENABLE_FEATURE_TAB_COMPLETION
+# undef ENABLE_FEATURE_USERNAME_COMPLETION
+# define ENABLE_FEATURE_EDITING_FANCY_PROMPT 0
+# define ENABLE_FEATURE_TAB_COMPLETION 0
+# define ENABLE_FEATURE_USERNAME_COMPLETION 0
+#endif
+
+
#define ENABLE_USERNAME_OR_HOMEDIR \
(ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT)
-#define IF_USERNAME_OR_HOMEDIR(...)
#if ENABLE_USERNAME_OR_HOMEDIR
-# undef IF_USERNAME_OR_HOMEDIR
# define IF_USERNAME_OR_HOMEDIR(...) __VA_ARGS__
+#else
+# define IF_USERNAME_OR_HOMEDIR(...) /*nothing*/
#endif
@@ -743,11 +754,11 @@
char *tmp;
char **res;
-#if EDITING_HAS_path_lookup
+# if EDITING_HAS_path_lookup
if (state->flags & WITH_PATH_LOOKUP)
pth = state->path_lookup;
else
-#endif
+# endif
pth = getenv("PATH");
/* PATH="" or PATH=":"? */
@@ -1885,9 +1896,7 @@
{
int prmt_size = 0;
char *prmt_mem_ptr = xzalloc(1);
-# if ENABLE_USERNAME_OR_HOMEDIR
char *cwd_buf = NULL;
-# endif
char flg_not_length = '[';
char cbuf[2];
@@ -1954,11 +1963,9 @@
c = *prmt_ptr++;
switch (c) {
-# if ENABLE_USERNAME_OR_HOMEDIR
case 'u':
pbuf = user_buf ? user_buf : (char*)"";
break;
-# endif
case 'H':
case 'h':
pbuf = free_me = safe_gethostname();
@@ -1976,7 +1983,6 @@
strftime_HHMMSS(timebuf, sizeof(timebuf), NULL)[-3] = '\0';
pbuf = timebuf;
break;
-# if ENABLE_USERNAME_OR_HOMEDIR
case 'w': /* current dir */
case 'W': /* basename of cur dir */
if (!cwd_buf) {
@@ -2003,7 +2009,6 @@
if (cp)
pbuf = (char*)cp + 1;
break;
-# endif
// bb_process_escape_sequence does this now:
// case 'e': case 'E': /* \e \E = \033 */
// c = '\033';
@@ -2064,10 +2069,8 @@
free(free_me);
} /* while */
-# if ENABLE_USERNAME_OR_HOMEDIR
if (cwd_buf != (char *)bb_msg_unknown)
free(cwd_buf);
-# endif
/* see comment (above this function) about multiline prompt redrawing */
cmdedit_prompt = prompt_last_line = prmt_mem_ptr;
prmt_ptr = strrchr(cmdedit_prompt, '\n');
@@ -2075,7 +2078,7 @@
prompt_last_line = prmt_ptr + 1;
put_prompt();
}
-#endif
+#endif /* FEATURE_EDITING_FANCY_PROMPT */
#if ENABLE_FEATURE_EDITING_WINCH
static void cmdedit_setwidth(void)