]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20060525 snapshot
authorChet Ramey <chet.ramey@case.edu>
Sun, 4 Dec 2011 03:48:47 +0000 (22:48 -0500)
committerChet Ramey <chet.ramey@case.edu>
Sun, 4 Dec 2011 03:48:47 +0000 (22:48 -0500)
CWRU/CWRU.chlog
CWRU/misc/open-files.c
redir.c
subst.c

index 543128612c6e7be2bb39b1fdd1f43932537616bf..eea5e4be1f6e05c2448020902f3a2ab54ff286ad 100644 (file)
@@ -13419,3 +13419,23 @@ lib/readline/undo.c
 
 lib/readline/rlprivate.h
        - new extern declarations for _rl_copy_undo_{entry,list}
+
+execute_cmd.c
+       - change execute_cond_node so that quoting the rhs of the =~
+         operator forces string matching, like the == and != operators
+
+                                  5/23
+                                  ----
+redir.c
+       - add_undo_redirect now takes as an additional argument the type of
+         redirection we're trying to undo
+       - don't add a "preservation" redirection for fds > SHELL_FD_BASE if
+         the redirection is closing the fd
+
+                                  5/24
+                                  ----
+subst.c
+       - make sure that parameter_brace_substring leaves this_command_name
+         set to either NULL or its previous value after setting it so that
+         arithmetic evaluation errors while expanding substring values
+         contain meaningful informationn
index aa4ab07414ce4b80529a4618c69cd9845edde5d8..ca3d26ed4a5e2ce9813bb2db0c995b438011c168 100644 (file)
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/file.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+
 #include <stdio.h>
 
 main()
diff --git a/redir.c b/redir.c
index c9e53351e8e42f476725d8e8b98db70b33ee3fd0..0bd2d5f51355d5f39d27a3e61f53c437e1ae9920 100644 (file)
--- a/redir.c
+++ b/redir.c
@@ -63,7 +63,7 @@ extern REDIRECT *exec_redirection_undo_list;
 /* Static functions defined and used in this file. */
 static void add_undo_close_redirect __P((int));
 static void add_exec_redirect __P((REDIRECT *));
-static int add_undo_redirect __P((int));
+static int add_undo_redirect __P((int, enum r_instruction));
 static int expandable_redirection_filename __P((REDIRECT *));
 static int stdin_redirection __P((enum r_instruction, int));
 static int do_redirection_internal __P((REDIRECT *, int));
@@ -630,8 +630,8 @@ do_redirection_internal (redirect, flags)
   redirector = redirect->redirector;
   ri = redirect->instruction;
 
-if (redirect->flags & RX_INTERNAL)
-  flags |= RX_INTERNAL;
+  if (redirect->flags & RX_INTERNAL)
+    flags |= RX_INTERNAL;
 
   if (TRANSLATE_REDIRECT (ri))
     {
@@ -757,7 +757,7 @@ if (redirect->flags & RX_INTERNAL)
            {
              /* Only setup to undo it if the thing to undo is active. */
              if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
-               add_undo_redirect (redirector);
+               add_undo_redirect (redirector, ri);
              else
                add_undo_close_redirect (redirector);
            }
@@ -808,7 +808,7 @@ if (redirect->flags & RX_INTERNAL)
          if (flags & RX_ACTIVE)
            {
              if (flags & RX_UNDOABLE)
-               add_undo_redirect (2);
+               add_undo_redirect (2, ri);
              if (dup2 (1, 2) < 0)
                return (errno);
            }
@@ -836,7 +836,7 @@ if (redirect->flags & RX_INTERNAL)
                {
                  /* Only setup to undo it if the thing to undo is active. */
                  if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
-                   add_undo_redirect (redirector);
+                   add_undo_redirect (redirector, ri);
                  else
                    add_undo_close_redirect (redirector);
                }
@@ -878,7 +878,7 @@ if (redirect->flags & RX_INTERNAL)
            {
              /* Only setup to undo it if the thing to undo is active. */
              if (fcntl (redirector, F_GETFD, 0) != -1)
-               add_undo_redirect (redirector);
+               add_undo_redirect (redirector, ri);
              else
                add_undo_close_redirect (redirector);
            }
@@ -925,7 +925,7 @@ if (redirect->flags & RX_INTERNAL)
       if (flags & RX_ACTIVE)
        {
          if ((flags & RX_UNDOABLE) && (fcntl (redirector, F_GETFD, 0) != -1))
-           add_undo_redirect (redirector);
+           add_undo_redirect (redirector, ri);
 
 #if defined (BUFFERED_INPUT)
          check_bash_input (redirector);
@@ -951,8 +951,9 @@ if (redirect->flags & RX_INTERNAL)
    even if REDIRECTION_UNDO_LIST is discarded by the exec builtin
    are also saved on EXEC_REDIRECTION_UNDO_LIST. */
 static int
-add_undo_redirect (fd)
+add_undo_redirect (fd, ri)
      int fd;
+     enum r_instruction ri;
 {
   int new_fd, clexec_flag;
   REDIRECT *new_redirect, *closer, *dummy_redirect;
@@ -990,7 +991,7 @@ add_undo_redirect (fd)
   /* experimental:  if we're saving a redirection to undo for a file descriptor
      above SHELL_FD_BASE, add a redirection to be undone if the exec builtin
      causes redirections to be discarded. */
-  if (fd >= SHELL_FD_BASE)
+  if (fd >= SHELL_FD_BASE && ri != r_close_this)
     {
       rd.dest = new_fd;
       new_redirect = make_redirection (fd, r_duplicating_output, rd);
diff --git a/subst.c b/subst.c
index 04a24f7232e3b76c77023ce3bdd8d73d31e1472c..cc1cfda8d3b54e851c4e951651adaba1a34caaa4 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -5485,22 +5485,27 @@ parameter_brace_substring (varname, value, substr, quoted)
 {
   intmax_t e1, e2;
   int vtype, r, starsub;
-  char *temp, *val, *tt;
+  char *temp, *val, *tt, *oname;
   SHELL_VAR *v;
 
   if (value == 0)
     return ((char *)NULL);
 
+  oname = this_command_name;
   this_command_name = varname;
 
   vtype = get_var_and_type (varname, value, quoted, &v, &val);
   if (vtype == -1)
-    return ((char *)NULL);
+    {
+      this_command_name = oname;
+      return ((char *)NULL);
+    }
 
   starsub = vtype & VT_STARSUB;
   vtype &= ~VT_STARSUB;
 
   r = verify_substring_values (val, substr, vtype, &e1, &e2);
+  this_command_name = oname;
   if (r <= 0)
     return ((r == 0) ? &expand_param_error : (char *)NULL);