hush: if !EDITING, do not regenerate prompt for every input char
function old new delta fgetc_interactive 261 258 -3 pseudo_exec_argv 406 399 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
15
shell/hush.c
15
shell/hush.c
@@ -2640,11 +2640,14 @@ static const char *setup_prompt_string(void)
|
|||||||
}
|
}
|
||||||
static int get_user_input(struct in_str *i)
|
static int get_user_input(struct in_str *i)
|
||||||
{
|
{
|
||||||
|
# if ENABLE_FEATURE_EDITING
|
||||||
|
/* In EDITING case, this function reads next input line,
|
||||||
|
* saves it in i->p, then returns 1st char of it.
|
||||||
|
*/
|
||||||
int r;
|
int r;
|
||||||
const char *prompt_str;
|
const char *prompt_str;
|
||||||
|
|
||||||
prompt_str = setup_prompt_string();
|
prompt_str = setup_prompt_string();
|
||||||
# if ENABLE_FEATURE_EDITING
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
reinit_unicode_for_hush();
|
reinit_unicode_for_hush();
|
||||||
G.flag_SIGINT = 0;
|
G.flag_SIGINT = 0;
|
||||||
@@ -2674,9 +2677,15 @@ static int get_user_input(struct in_str *i)
|
|||||||
i->p = G.user_input_buf;
|
i->p = G.user_input_buf;
|
||||||
return (unsigned char)*i->p++;
|
return (unsigned char)*i->p++;
|
||||||
# else
|
# else
|
||||||
|
/* In !EDITING case, this function gets called for every char.
|
||||||
|
* Buffering happens deeper in the call chain, in hfgetc(i->file).
|
||||||
|
*/
|
||||||
|
int r;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
G.flag_SIGINT = 0;
|
G.flag_SIGINT = 0;
|
||||||
if (i->last_char == '\0' || i->last_char == '\n') {
|
if (i->last_char == '\0' || i->last_char == '\n') {
|
||||||
|
const char *prompt_str = setup_prompt_string();
|
||||||
/* Why check_and_run_traps here? Try this interactively:
|
/* Why check_and_run_traps here? Try this interactively:
|
||||||
* $ trap 'echo INT' INT; (sleep 2; kill -INT $$) &
|
* $ trap 'echo INT' INT; (sleep 2; kill -INT $$) &
|
||||||
* $ <[enter], repeatedly...>
|
* $ <[enter], repeatedly...>
|
||||||
@@ -8171,7 +8180,6 @@ static void exec_function(char ***to_free,
|
|||||||
|
|
||||||
/* On MMU, funcp->body is always non-NULL */
|
/* On MMU, funcp->body is always non-NULL */
|
||||||
n = run_list(funcp->body);
|
n = run_list(funcp->body);
|
||||||
fflush_all();
|
|
||||||
_exit(n);
|
_exit(n);
|
||||||
# else
|
# else
|
||||||
//? close_saved_fds_and_FILE_fds();
|
//? close_saved_fds_and_FILE_fds();
|
||||||
@@ -8246,7 +8254,6 @@ static void exec_builtin(char ***to_free,
|
|||||||
{
|
{
|
||||||
#if BB_MMU
|
#if BB_MMU
|
||||||
int rcode;
|
int rcode;
|
||||||
fflush_all();
|
|
||||||
//? close_saved_fds_and_FILE_fds();
|
//? close_saved_fds_and_FILE_fds();
|
||||||
rcode = x->b_function(argv);
|
rcode = x->b_function(argv);
|
||||||
fflush_all();
|
fflush_all();
|
||||||
@@ -10040,7 +10047,7 @@ int hush_main(int argc, char **argv)
|
|||||||
|
|
||||||
cached_getpid = getpid(); /* for tcsetpgrp() during init */
|
cached_getpid = getpid(); /* for tcsetpgrp() during init */
|
||||||
G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */
|
G.root_pid = cached_getpid; /* for $PID (NOMMU can override via -$HEXPID:HEXPPID:...) */
|
||||||
G.root_ppid = getppid(); /* for $$PPID (NOMMU can override) */
|
G.root_ppid = getppid(); /* for $PPID (NOMMU can override) */
|
||||||
|
|
||||||
/* Deal with HUSH_VERSION */
|
/* Deal with HUSH_VERSION */
|
||||||
debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION");
|
debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION");
|
||||||
|
Reference in New Issue
Block a user