]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190111 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 14 Jan 2019 15:44:20 +0000 (10:44 -0500)
committerChet Ramey <chet.ramey@case.edu>
Mon, 14 Jan 2019 15:44:20 +0000 (10:44 -0500)
CWRU/CWRU.chlog
builtins/hash.def
lib/glob/glob.c
parse.y
parser.h
tests/alias.right
tests/alias4.sub
variables.c

index 30124c5591db67c5005161448b6b44e9ccd03689..e972bf4ede598f286d5605db1e2fd0dfe786a7bb 100644 (file)
@@ -5026,3 +5026,38 @@ test.c
 arrayfunc.c
        - array_expand_index: call evalexp with EXP_EXPANDED flag, since we
          have run the string through expand_arith_string already
+
+                                  1/11
+                                  ----
+parser.h
+       - PST_ENDALIAS: new state, means we just consumed the last character
+         of an alias expansion and returned the fake space
+
+parse.y
+       - shell_getc: add PST_ENDALIAS to parser_state before returning the
+         fake space that marks the end of the alias, making sure to do it
+         only once. With that set, fall through to the pop_string(), making
+         sure to unset PST_ENDALIAS. Fixes alias bug reported by
+         Ante Peric <synthmeat@gmail.com>
+
+                                  1/12
+                                  ----
+lib/glob/glob.c
+       - {extglob,wextglob}_skipname: make sure we check the rest of the
+         pattern if the extglob pattern is null, and therefore won't match
+         anything. If that is followed by a `.', quoted or unquoted, we can
+         match a leading `.' in the pathname. This code is currently not
+         active.
+
+builtins/hash.def
+       - hash_builtin: if -d is supplied without an argument, print an error
+         message and return failure, just like -t without an argument. Fixes
+         inconsistency reported by Dan Jacobson <jidanni@jidanni.org>
+
+                                  1/13
+                                  ----
+parse.y
+       - shell_getc: use shellblank when testing the last character of an
+         alias to determine whether or not to add a trailing space instead
+         of testing against a space only. These are the non-shell-metacharacters
+         that can delimit words. Used together with PST_ENDALIAS
index b303930812ca628ea06fdb238710f80416c413be..4de3a910d408a1091d28123ab018cb6d6f671e63 100644 (file)
@@ -123,9 +123,9 @@ hash_builtin (list)
   list = loptend;
 
   /* hash -t requires at least one argument. */
-  if (list == 0 && list_targets)
+  if (list == 0 && (delete || list_targets))
     {
-      sh_needarg ("-t");
+      sh_needarg (delete ? "-d" : "-t");
       return (EXECUTION_FAILURE);
     }
 
index 22d90a5cdf9c6c579ac2c8c1f7b111e8d932d58c..79ab93398680699bf0823e5dafd393d4c6ed1170 100644 (file)
@@ -187,7 +187,7 @@ extglob_skipname (pat, dname, flags)
      int flags;
 {
   char *pp, *pe, *t, *se;
-  int n, r, negate, wild;
+  int n, r, negate, wild, nullpat;
 
   negate = *pat == '!';
   wild = *pat == '*' || *pat == '?';
@@ -214,6 +214,11 @@ extglob_skipname (pat, dname, flags)
       return r;
     }
 
+  /* Is the extglob pattern between the parens the null pattern?  The null
+     pattern can match nothing, so should we check any remaining portion of
+     the pattern? */
+  nullpat = pe >= (pat + 2) && pe[-2] == '(' && pe[-1] == ')';
+
   /* check every subpattern */
   while (t = glob_patscan (pp, pe, '|'))
     {
@@ -305,7 +310,7 @@ wextglob_skipname (pat, dname, flags)
 {
 #if EXTENDED_GLOB
   wchar_t *pp, *pe, *t, n, *se;
-  int r, negate, wild;
+  int r, negate, wild, nullpat;
 
   negate = *pat == L'!';
   wild = *pat == L'*' || *pat == L'?';
@@ -323,6 +328,11 @@ wextglob_skipname (pat, dname, flags)
       return r;
     }
 
+  /* Is the extglob pattern between the parens the null pattern?  The null
+     pattern can match nothing, so should we check any remaining portion of
+     the pattern? */
+  nullpat = pe >= (pat + 2) && pe[-2] == L'(' && pe[-1] == L')';
+
   /* check every subpattern */
   while (t = glob_patscan_wc (pp, pe, '|'))
     {
diff --git a/parse.y b/parse.y
index 3ff87bccc06c1f9ace9cdf2d0dd02ab506e36f9c..07e6e3e44a9a87c8103ad0415b1d3384ae5066e7 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -2557,12 +2557,14 @@ next_alias_char:
   if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE &&
       pushed_string_list->flags != PSH_DPAREN &&
       (parser_state & PST_COMMENT) == 0 &&
+      (parser_state & PST_ENDALIAS) == 0 &&    /* only once */
       shell_input_line_index > 0 &&
-      shell_input_line[shell_input_line_index-1] != ' ' &&
+      shellblank (shell_input_line[shell_input_line_index-1]) == 0 &&
       shell_input_line[shell_input_line_index-1] != '\n' &&
       shellmeta (shell_input_line[shell_input_line_index-1]) == 0 &&
       (current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"'))
     {
+      parser_state |= PST_ENDALIAS;
       return ' ';      /* END_ALIAS */
     }
 #endif
@@ -2571,6 +2573,7 @@ pop_alias:
   /* This case works for PSH_DPAREN as well */
   if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
     {
+      parser_state &= ~PST_ENDALIAS;
       pop_string ();
       uc = shell_input_line[shell_input_line_index];
       if (uc)
index 54dd2c889850b552d2cb75ffd52fb55d56b44bcb..59bddacaf6405553a6ea00611bea7e00db411ec7 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -1,7 +1,7 @@
 /* parser.h -- Everything you wanted to know about the parser, but were
    afraid to ask. */
 
-/* Copyright (C) 1995-2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -47,6 +47,7 @@
 #define PST_REPARSE    0x040000        /* re-parsing in parse_string_to_word_list */
 #define PST_REDIRLIST  0x080000        /* parsing a list of redirections preceding a simple command name */
 #define PST_COMMENT    0x100000        /* parsing a shell comment; used by aliases */
+#define PST_ENDALIAS   0x200000        /* just finished expanding and consuming an alias */
 
 /* Definition of the delimiter stack.  Needed by parse.y and bashhist.c. */
 struct dstack {
index 3ab9a71716155c3897efa7e05a858e1f1b281ba8..398c69e650c5f91416058fa55bebbf5dfa535b78 100644 (file)
@@ -30,3 +30,4 @@ a b
 a a b
 ok 3
 ok 4
+bar
index 6ea513a17ee0bba3c18c1ed23c7987b653494287..b205fee753a26f677e09a9c276790a1c3f569a7d 100644 (file)
@@ -68,3 +68,10 @@ long_comment text after
 
 # comment
 comment foo bar
+
+# alias ending in a tab
+alias foo="\
+       echo \"bar\" \
+       "
+
+foo
index 610629abbaf8116e49a606f42629cdbff66ef6a4..f6346eb5931e07a0eed5b6e98f88f061f93471f9 100644 (file)
@@ -4775,7 +4775,6 @@ make_env_array_from_var_list (vars)
             using the cached exportstr... */
          list[list_index] = USE_EXPORTSTR ? savestring (value)
                                           : mk_env_string (var->name, value, function_p (var));
-
          if (USE_EXPORTSTR == 0)
            SAVE_EXPORTSTR (var, list[list_index]);