mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-08 03:02:40 +02:00
update fix to save history if fatal signal arrives during $PROMPT_COMMAND execution; fix issue with extglob and empty patterns preceding pattern beginning with a `.'
This commit is contained in:
+11
-6
@@ -1,6 +1,6 @@
|
||||
/* glob.c -- file-name wildcard pattern matching for Bash.
|
||||
|
||||
Copyright (C) 1985-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1985-2026 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne-Again SHell.
|
||||
|
||||
@@ -279,13 +279,16 @@ skipname (char *pat, char *dname, int flags)
|
||||
literal `.'. This is the negation of the next clause. */
|
||||
else if ((flags & GX_NEGATE) && noglob_dot_filenames == 0 &&
|
||||
dname[0] == '.' &&
|
||||
(pat[0] == '.' || (pat[0] == '\\' && pat[1] == '.')))
|
||||
(pat[0] && pat[0] == '.' || (pat[0] == '\\' && pat[1] == '.')))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/* If a dot must be explicitly matched, check to see if they do. */
|
||||
/* If a dot must be explicitly matched, check to see if the
|
||||
pattern and dirname both have one. */
|
||||
/* This allows the empty pattern to `match' a `.', deferring the match
|
||||
until later. */
|
||||
else if (noglob_dot_filenames && dname[0] == '.' &&
|
||||
pat[0] != '.' && (pat[0] != '\\' || pat[1] != '.'))
|
||||
pat[0] && pat[0] != '.' && (pat[0] != '\\' || pat[1] != '.'))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -312,14 +315,16 @@ wskipname (wchar_t *pat, wchar_t *dname, int flags)
|
||||
literal `.'. This is the negation of the next clause. */
|
||||
else if ((flags & GX_NEGATE) && noglob_dot_filenames == 0 &&
|
||||
dname[0] == L'.' &&
|
||||
(pat[0] == L'.' || (pat[0] == L'\\' && pat[1] == L'.')))
|
||||
(pat[0] != L'\0' && pat[0] == L'.' || (pat[0] == L'\\' && pat[1] == L'.')))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/* If a leading dot must be explicitly matched, check to see if the
|
||||
pattern and dirname both have one. */
|
||||
/* This allows the empty pattern to `match' a `.', deferring the match
|
||||
until later. */
|
||||
else if (noglob_dot_filenames && dname[0] == L'.' &&
|
||||
pat[0] != L'.' && (pat[0] != L'\\' || pat[1] != L'.'))
|
||||
pat[0] && pat[0] != L'.' && (pat[0] != L'\\' || pat[1] != L'.'))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
+6
-4
@@ -786,14 +786,15 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
|
||||
|
||||
switch (xc)
|
||||
{
|
||||
case L('+'): /* match one or more occurrences */
|
||||
case L('*'): /* match zero or more occurrences */
|
||||
/* If we can get away with no matches, don't even bother. Just
|
||||
call GMATCH on the rest of the pattern and return success if
|
||||
it succeeds. */
|
||||
if (xc == L('*') && (GMATCH (s, se, prest, pe, NULL, flags) == 0))
|
||||
if (GMATCH (s, se, prest, pe, NULL, flags) == 0)
|
||||
return 0;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case L('+'): /* match one or more occurrences */
|
||||
/* OK, we have to do this the hard way. First, we make sure one of
|
||||
the subpatterns matches, then we try to match the rest of the
|
||||
string. */
|
||||
@@ -824,13 +825,14 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
|
||||
return (FNM_NOMATCH);
|
||||
|
||||
case L('?'): /* match zero or one of the patterns */
|
||||
case L('@'): /* match one (or more) of the patterns */
|
||||
/* If we can get away with no matches, don't even bother. Just
|
||||
call gmatch on the rest of the pattern and return success if
|
||||
it succeeds. */
|
||||
if (xc == L('?') && (GMATCH (s, se, prest, pe, NULL, flags) == 0))
|
||||
if ((GMATCH (s, se, prest, pe, NULL, flags) == 0))
|
||||
return 0;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case L('@'): /* match one (or more) of the patterns */
|
||||
/* OK, we have to do this the hard way. First, we see if one of
|
||||
the subpatterns matches, then, if it does, we try to match the
|
||||
rest of the string. */
|
||||
|
||||
Reference in New Issue
Block a user