From: Chet Ramey Date: Wed, 30 Jan 2019 19:38:09 +0000 (-0500) Subject: commit bash-20190125 snapshot X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca5d21091bb80ac41dc4bf7c9361c217b00b0b81;p=thirdparty%2Fbash.git commit bash-20190125 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 386e558cf..caf2e2d4d 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -5078,3 +5078,47 @@ general.c whether or not the word consists of all digits. This allows function names to consist solely of digits when not in posix mode. From a report by Andrey Butirsky + + 1/22 + ---- +bashline.c + - initialize_readline: only unbind ^E in vi_movement_keymap if it's + still bound to the default rl_emacs_editing_mode. Fixes bug + reported by Greg Bell + + 1/23 + ---- +builtins/shopt.def + - we need the extern declaration for syslog_history if SYSLOG_HISTORY + is defined, since it's used even if SYSLOG_SHOPT is not defined + + 1/25 + ---- +command.h + - CMD_TRY_OPTIMIZING: new command flag, means this (simple) command is + a candidate for fork optimization (suppression) + +builtins/evalstring.c + - can_optimize_connection: new function, takes an AND_OR list (&& or + ||) from parse_and_execute, makes sure it's the last in a possibly + multi-command list, and returns non-zero if it's a simple command, + indicating that it's a candidate for fork optimization. + - parse_and_execute: if we have a cm_connection command, call + can_optimize_connection to determine if it's a suitable candidate + and set CMD_TRY_OPTIMIZING if that returns non-zero + - optimize_fork: don't bother unless the rhs of the && or || command + has the CMD_TRY_OPTIMIZING flag set. These fix the bug reported by + Brad Spencer + +execute_cmd.c + - execute_connection: case AND_AND and OR_OR: call optimize_fork on + the right side of the command before executing `second'. This will + safely restore the fork optimization we removed from + parse_and_execute() + +builtins/complete.def + - build_actions: make sure the function name argument to -F is a + valid shell function name: it doesn't contain any invalid posix- + mode characters and doesn't contain any shell break characters that + would need to be quoted when defining a function. Fixes issue + reported by Great Big Dot diff --git a/bashline.c b/bashline.c index f5d90a516..489be690e 100644 --- a/bashline.c +++ b/bashline.c @@ -497,7 +497,10 @@ initialize_readline () if (func == rl_vi_editing_mode) rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap); #if defined (VI_MODE) - rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap); + kseq[0] = CTRL('E'); + func = rl_function_of_keyseq (kseq, vi_movement_keymap, (int *)NULL); + if (func == rl_emacs_editing_mode) + rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap); #endif #if defined (BRACE_COMPLETION) diff --git a/builtins/common.h b/builtins/common.h index f0687640d..bfc294ecc 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -203,6 +203,7 @@ extern int evalstring __P((char *, const char *, int)); extern void parse_and_execute_cleanup __P((int)); extern int parse_string __P((char *, const char *, int, char **)); extern int should_suppress_fork __P((COMMAND *)); +extern int can_optimize_connection __P((COMMAND *)); extern void optimize_fork __P((COMMAND *)); extern void optimize_subshell_command __P((COMMAND *)); diff --git a/builtins/complete.def b/builtins/complete.def index 76b3eedd8..6bc3087c5 100644 --- a/builtins/complete.def +++ b/builtins/complete.def @@ -193,6 +193,7 @@ build_actions (list, flagp, actp, optp) { int opt, ind, opt_given; unsigned long acts, copts; + WORD_DESC w; acts = copts = (unsigned long)0L; opt_given = 0; @@ -323,7 +324,13 @@ build_actions (list, flagp, actp, optp) return (EX_USAGE); } case 'F': - Farg = list_optarg; + w.word = Farg = list_optarg; + w.flags = 0; + if (check_identifier (&w, posixly_correct) == 0 || strcspn (Farg, shell_break_chars)) + { + sh_invalidid (Farg); + return (EX_USAGE); + } break; case 'G': Garg = list_optarg; diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 1496eeec2..7a110d959 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -100,12 +100,22 @@ should_suppress_fork (command) ((command->flags & CMD_INVERT_RETURN) == 0)); } +int +can_optimize_connection (command) + COMMAND *command; +{ + return (*bash_input.location.string == '\0' && + (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) && + command->value.Connection->second->type == cm_simple); +} + void optimize_fork (command) COMMAND *command; { if (command->type == cm_connection && (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) && + (command->value.Connection->second->flags & CMD_TRY_OPTIMIZING) && should_suppress_fork (command->value.Connection->second)) { command->value.Connection->second->flags |= CMD_NO_FORK; @@ -412,8 +422,18 @@ parse_and_execute (string, from_file, flags) command->flags |= CMD_NO_FORK; command->value.Simple->flags |= CMD_NO_FORK; } - else if (command->type == cm_connection) - optimize_fork (command); + + /* Can't optimize forks out here execept for simple commands. + This knows that the parser sets up commands as left-side heavy + (&& and || are left-associative) and after the single parse, + if we are at the end of the command string, the last in a + series of connection commands is + command->value.Connection->second. */ + else if (command->type == cm_connection && can_optimize_connection (command)) + { + command->value.Connection->second->flags |= CMD_TRY_OPTIMIZING; + command->value.Connection->second->value.Simple->flags |= CMD_TRY_OPTIMIZING; + } #endif /* ONESHOT */ /* See if this is a candidate for $( value.Connection->connector == OR_OR) && (exec_result != EXECUTION_SUCCESS))) { + optimize_fork (command); + second = command->value.Connection->second; if (ignore_return && second) second->flags |= CMD_IGNORE_RETURN;