]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190125 snapshot
authorChet Ramey <chet.ramey@case.edu>
Wed, 30 Jan 2019 19:38:09 +0000 (14:38 -0500)
committerChet Ramey <chet.ramey@case.edu>
Wed, 30 Jan 2019 19:38:09 +0000 (14:38 -0500)
CWRU/CWRU.chlog
bashline.c
builtins/common.h
builtins/complete.def
builtins/evalstring.c
builtins/shopt.def
command.h
doc/bash.1
doc/bashref.texi
doc/version.texi
execute_cmd.c

index 386e558cf5b42624596a18f30b3abadaa323dbbc..caf2e2d4d0226af38a85ba22f72375ed86f28e98 100644 (file)
@@ -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 <butirsky@gmail.com>
+
+                                  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 <gbell_spamless@yahoo.com>
+
+                                  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 <bspencer@blackberry.com>
+
+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 <greatbigdot@gmail.com>
index f5d90a5160686982bc0ed58275e2b52e4ffbc1d6..489be690e6e11a7bccf5957d8000bad473fd0321 100644 (file)
@@ -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)
index f0687640dd8fa8d1e102118a9597b1c2590a3302..bfc294eccdee5057f833af7c8321bd28875b2992 100644 (file)
@@ -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 *));
 
index 76b3eedd82ef7699ca05e3b7af07b939d32bf138..6bc3087c5b8eed176f8858c51f218d8644665576 100644 (file)
@@ -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;
index 1496eeec2c01e7fa01c14bf4f965e0a20a964268..7a110d95968cf50918ac0f4611060bdd22a3d593 100644 (file)
@@ -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 $( <file ). */
index f6dc6f97cf3c2c4921b8a837076bcdc0b63a210b..1c4853611f5fbc278d87a67b1cc999a61e4ee24d 100644 (file)
@@ -122,7 +122,7 @@ extern int assoc_expand_once;
 extern int array_expand_once;
 #endif
 
-#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
+#if defined (SYSLOG_HISTORY)
 extern int syslog_history;
 #endif
 
index 32495162af65d1eb3af0944c6b193b070646cba2..b9e9b6693b0b19edcb859465f89a96e5243cd3b3 100644 (file)
--- a/command.h
+++ b/command.h
@@ -186,6 +186,7 @@ typedef struct element {
 #define CMD_COPROC_SUBSHELL 0x1000
 #define CMD_LASTPIPE       0x2000
 #define CMD_STDPATH        0x4000      /* use standard path for command lookup */
+#define CMD_TRY_OPTIMIZING  0x8000     /* try to optimize this simple command */
 
 /* What a command looks like. */
 typedef struct command {
index 825fb3096fa6202ef47070e17cc885cb48ce4591..d1cdcfad1c8927567f39a8648197a27cca3164b6 100644 (file)
@@ -5,12 +5,12 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Fri Dec  7 09:48:47 EST 2018
+.\"    Last Change: Sun Jan 27 17:41:59 EST 2019
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2018 December 7" "GNU Bash 5.0"
+.TH BASH 1 "2019 January 27" "GNU Bash 5.0"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -893,7 +893,8 @@ Using \fB;&\fP in place of \fB;;\fP causes execution to continue with
 the \fIlist\fP associated with the next set of patterns.
 Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next
 pattern list in the statement, if any, and execute any associated \fIlist\fP
-on a successful match.
+on a successful match,
+continuing the case statement execution as if the pattern list had not matched.
 The exit status is zero if no
 pattern matches.  Otherwise, it is the exit status of the
 last command executed in \fIlist\fP.
index fc0229737a5a6152c87564d54be7ca5f889a0d41..f62437d5b34836a1de577a8372957a9e01071fc5 100644 (file)
@@ -933,7 +933,8 @@ Using @samp{;&}  in place of @samp{;;} causes execution to continue with
 the @var{command-list} associated with the next clause, if any.
 Using @samp{;;&} in place of @samp{;;} causes the shell to test the patterns
 in the next clause, if any, and execute any associated @var{command-list}
-on a successful match.
+on a successful match,
+continuing the case statement execution as if the pattern list had not matched.
 
 The return status is zero if no @var{pattern} is matched.  Otherwise, the
 return status is the exit status of the @var{command-list} executed.
index 12462477f88d8114be28a83108046ef0b5d8f95e..48cb8f2a7342b7e0b5aefe9e10082ac2e28eee10 100644 (file)
@@ -1,11 +1,11 @@
 @ignore
-Copyright (C) 1988-2018 Free Software Foundation, Inc.
+Copyright (C) 1988-2019 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Fri Dec  7 09:49:07 EST 2018
+@set LASTCHANGE Sun Jan 27 17:41:35 EST 2019
 
 @set EDITION 5.0
 @set VERSION 5.0
 
-@set UPDATED 7 December 2018
-@set UPDATED-MONTH December 2018
+@set UPDATED 27 January 2019
+@set UPDATED-MONTH January 2019
index 686ecfe9425919081edb63e3fc231d5ec0322b6b..908b88ee8da3dd9e32ee5943db724c6b5bffebc1 100644 (file)
@@ -2767,6 +2767,8 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
          ((command->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;