]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190109 snapshot
authorChet Ramey <chet.ramey@case.edu>
Thu, 10 Jan 2019 16:56:16 +0000 (11:56 -0500)
committerChet Ramey <chet.ramey@case.edu>
Thu, 10 Jan 2019 16:56:16 +0000 (11:56 -0500)
12 files changed:
CWRU/CWRU.chlog
arrayfunc.c
bashline.c
builtins/declare.def
builtins/return.def
examples/loadables/push.c
execute_cmd.c
lib/glob/glob_loop.c
subst.c
test.c
tests/glob.right
tests/glob4.sub

index 7367e0bf0fdbd577adc9d8f805d18040a386ffc3..30124c5591db67c5005161448b6b44e9ccd03689 100644 (file)
@@ -4970,12 +4970,6 @@ lib/glob/glob_loop.c
 
                                 1/6/2019
                                 --------
-execute_cmd.c
-       - execute_simple_command: catch all non-zero special builtin errors
-         (e.g. return not in a function) and make sure a non-interactive
-         posix-mode shell exits. Old code expected builtins to signal
-         internal fatal errors with code > 256. Fixes bug reported by
-         Robert Hailey <bash@osndok.com>
 
 examples/loadables/basename.c
        - make sure to include bashgetopt.h. Reported by Angel 
@@ -4993,3 +4987,42 @@ lib/readline/unicode.c
        - u32toutf16: correct the second argument to be wchar_t *, and treat
          it as such, even though it doesn't make a difference in practice.
          Report and fix from Eduardo Bustamante <dualbus@gmail.com>
+
+                                   1/8
+                                   ---
+
+builtins/return.def
+       - return_builtin: return EX_USAGE if we're not executing a shell
+         function or sourcing a script, so a posix-mode shell exits. Fixes
+         bug reported by Robert Hailey <bash@osndok.com>
+
+builtins/declare.def
+       - declare_internal: don't let `declare -f +f' turn off the function
+         attribute. Fix from Grisha Levit <grishalevit@gmail.com>
+       - declare_internal: reject attempts to add the -A or -a attributes
+         to functions. Report from Grisha Levit <grishalevit@gmail.com>
+
+                                   1/9
+                                   ---
+bashline.c
+       - completion_glob_pattern: new function, returns true if the passed
+         string contains a glob pattern that should be process by the glob
+         completion code. Completion glob patterns don't pay attention to
+         backslashes unless they're the last character in the string. This
+         is a different, more self-contained, fix for the problem reported
+         by Tom Ryder <tom@sanctum.geek.nz>
+
+lib/glob/glob_loop.c
+       - INTERNAL_GLOB_PATTERN_P: restore change from 4/27 and make this
+         function return non-zero if it encounters a backslash in the string.
+         It needs to match pathexp.c:unquoted_glob_pattern_p(). Adds fix
+         back for issue reported by axel@freakout.de
+
+test.c
+       - arithcomp: when calling evalexp, make sure to call it with the
+         EXP_EXPANDED flag, since all arguments here have been evaluated
+         already
+
+arrayfunc.c
+       - array_expand_index: call evalexp with EXP_EXPANDED flag, since we
+         have run the string through expand_arith_string already
index e4ae34d05fcc5ea8db2be8ade8d45b3dcfa245b1..7631e5ab6e65203fc0559bdf8bff198f07e916b6 100644 (file)
@@ -963,7 +963,7 @@ array_expand_index (var, s, len, flags)
   t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB);   /* XXX - Q_ARRAYSUB for future use */
   savecmd = this_command_name;
   this_command_name = (char *)NULL;
-  val = evalexp (t, 0, &expok);
+  val = evalexp (t, EXP_EXPANDED, &expok);     /* XXX - was 0 but we expanded exp already */
   this_command_name = savecmd;
   if (t != exp)
     free (t);
index 2846aabf7cb4a84d9699fc2c07bac6edba1e8c8e..ff79b7048d80bd761fef9c1df6d0ce1ffd9e796b 100644 (file)
@@ -1,6 +1,6 @@
 /* bashline.c -- Bash's interface to the readline library. */
 
-/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -231,6 +231,7 @@ static int bash_possible_variable_completions __P((int, int));
 static int bash_complete_command __P((int, int));
 static int bash_possible_command_completions __P((int, int));
 
+static int completion_glob_pattern __P((const char *));
 static char *glob_complete_word __P((const char *, int));
 static int bash_glob_completion_internal __P((int));
 static int bash_glob_complete_word __P((int, int));
@@ -1741,7 +1742,7 @@ bash_default_completion (text, start, end, qc, compflags)
 
   /* This could be a globbing pattern, so try to expand it using pathname
      expansion. */
-  if (!matches && glob_pattern_p (text))
+  if (!matches && completion_glob_pattern (text))
     {
       matches = rl_completion_matches (text, glob_complete_word);
       /* A glob expression that matches more than one filename is problematic.
@@ -1850,7 +1851,7 @@ command_word_completion_function (hint_text, state)
          glob_matches = (char **)NULL;
        }
 
-      globpat = glob_pattern_p (hint_text);
+      globpat = completion_glob_pattern (hint_text);
 
       /* If this is an absolute program name, do not check it against
         aliases, reserved words, functions or builtins.  We must check
@@ -3713,6 +3714,61 @@ bash_complete_command_internal (what_to_do)
   return bash_specific_completion (what_to_do, command_word_completion_function);
 }
 
+static int
+completion_glob_pattern (string)
+     const char *string;
+{
+  register int c;
+  char *send;
+  int open;
+
+  DECLARE_MBSTATE;
+
+  open = 0;
+  send = string + strlen (string);
+
+  while (c = *string++)
+    {
+      switch (c)
+       {
+       case '?':
+       case '*':
+         return (1);
+
+       case '[':
+         open++;
+         continue;
+
+       case ']':
+         if (open)
+           return (1);
+         continue;
+
+       case '+':
+       case '@':
+       case '!':
+         if (*string == '(')   /*)*/
+           return (1);
+         continue;
+
+       case '\\':
+         if (*string == 0)
+           return (0);           
+       }
+
+      /* Advance one fewer byte than an entire multibyte character to
+        account for the auto-increment in the loop above. */
+#ifdef HANDLE_MULTIBYTE
+      string--;
+      ADVANCE_CHAR_P (string, send - string);
+      string++;
+#else
+      ADVANCE_CHAR_P (string, send - string);
+#endif
+    }
+  return (0);
+}
+
 static char *globtext;
 static char *globorig;
 
@@ -3877,7 +3933,7 @@ bash_vi_complete (count, key)
       t = substring (rl_line_buffer, p, rl_point);
     }      
 
-  if (t && glob_pattern_p (t) == 0)
+  if (t && completion_glob_pattern (t) == 0)
     rl_explicit_arg = 1;       /* XXX - force glob_complete_word to append `*' */
   FREE (t);
 
index 7eac6f5839f0abb52456a8bdddd22de29eabe9ea..3fd1eb64ff757797d0b1713d2dabffe463290037 100644 (file)
@@ -533,7 +533,12 @@ restart_new_var_name:
                      any_failed++;
                      NEXT_VARIABLE ();
                    }
-
+                 else if (flags_on & (att_array|att_assoc))
+                   {
+                     sh_invalidopt ((flags_on & att_array) ? "-a" : "-A");
+                     any_failed++;
+                     NEXT_VARIABLE ();
+                   }
                  /* declare -[Ff] name [name...] */
                  if (flags_on == att_function && flags_off == 0)
                    {
@@ -558,6 +563,7 @@ restart_new_var_name:
                  else          /* declare -[fF] -[rx] name [name...] */
                    {
                      VSETATTR (var, flags_on);
+                     flags_off &= ~att_function;       /* makes no sense */
                      VUNSETATTR (var, flags_off);
                    }
                }
index 77e8d7c78ce5c2b214cabb6e9f1bb3b172d98385..03c98eb11a5d4aabe237b0156d7569a458b53978 100644 (file)
@@ -66,6 +66,6 @@ return_builtin (list)
   else
     {
       builtin_error (_("can only `return' from a function or sourced script"));
-      return (EXECUTION_FAILURE);
+      return (EX_USAGE);
     }
 }
index 9bcd5c3240961c58a51f65d8087e25c5fb27635e..194487c0c0207fd14a200eed649e529cdea93a20 100644 (file)
@@ -35,7 +35,7 @@
 extern int errno;
 #endif
 
-extern int dollar_dollar_pid;
+extern pid_t dollar_dollar_pid;
 extern int last_command_exit_value;
 
 int
index 75b9804b4c916cca7ee3747a83611caed2648140..686ecfe9425919081edb63e3fc231d5ec0322b6b 100644 (file)
@@ -4504,8 +4504,6 @@ run_builtin:
                  if (builtin_is_special)
                    special_builtin_failed = 1; /* XXX - take command builtin into account? */
                }
-             else
-               special_builtin_failed = builtin_is_special && result != EXECUTION_SUCCESS;
 
              /* In POSIX mode, if there are assignment statements preceding
                 a special builtin, they persist after the builtin
index 5f319cc2efa70986c3672b57022fd11a3b9a0492..7d6ae2113c509ec64a9087b03ce4c04e67b217b9 100644 (file)
@@ -54,17 +54,11 @@ INTERNAL_GLOB_PATTERN_P (pattern)
        continue;
 
       case L('\\'):
-#if 0
        /* Don't let the pattern end in a backslash (GMATCH returns no match
           if the pattern ends in a backslash anyway), but otherwise return 1,
           since the matching engine uses backslash as an escape character
           and it can be removed. */
        return (*p != L('\0'));
-#else
-       /* The pattern may not end with a backslash. */
-       if (*p++ == L('\0'))
-         return 0;
-#endif
       }
 
   return 0;
diff --git a/subst.c b/subst.c
index 95591878ca568903f93e3cdd5b5dd9a35bf095bf..4173547d2c26c665e2ea0fe03a4424faa41e44bd 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3565,6 +3565,10 @@ expand_arith_string (string, quoted)
       /* This is expanded version of expand_string_internal as it's called by
         expand_string_leave_quoted  */
       td.flags = W_NOPROCSUB|W_NOTILDE;        /* don't want process substitution or tilde expansion */
+#if 0  /* TAG:bash-5.1 */
+      if (quoted & Q_ARRAYSUB)
+       td.flags |= W_NOCOMSUB;
+#endif
       td.word = savestring (string);
       list = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);
       /* This takes care of the calls from expand_string_leave_quoted and
diff --git a/test.c b/test.c
index 4cb3343cda15171b22d145ce68e9e88f44210a7c..f007be8fe434bd621e2799a8d923e2c5bd70f981 100644 (file)
--- a/test.c
+++ b/test.c
@@ -344,10 +344,10 @@ arithcomp (s, t, op, flags)
 
   if (flags & TEST_ARITHEXP)
     {
-      l = evalexp (s, 0, &expok);
+      l = evalexp (s, EXP_EXPANDED, &expok);
       if (expok == 0)
        return (FALSE);         /* should probably longjmp here */
-      r = evalexp (t, 0, &expok);
+      r = evalexp (t, EXP_EXPANDED, &expok);
       if (expok == 0)
        return (FALSE);         /* ditto */
     }
index 1ead7b61da1d76dd083317b89dc0c09c0a7225b3..964d83d1eeb19bbcb70be8230e7ee6d9bd32c3c3 100644 (file)
@@ -61,6 +61,8 @@ a?
 argv[1] = <a\?>
 a?
 aa
+<define\/\
+/>
 argv[1] = <a>
 argv[2] = <abc>
 argv[3] = <abd>
index 378b5a92647127d37158254bf5bd2afcdcbf18e8..2733eb77c4a31854d4b7e3fe8847c887c0905133 100644 (file)
@@ -11,3 +11,9 @@ printf "%s\n" ${var}
 
 var='a\a'
 printf "%s\n" ${var}
+
+# shell's idea of a glob pattern and libglob's idea of a glob pattern have to
+# be identical
+PRE='\/'
+printf '<%s>\n' 'define'${PRE}'\
+/'