]> git.ipfire.org Git - thirdparty/bash.git/blame - pathexp.h
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / pathexp.h
CommitLineData
ccc6cda3
JA
1/* pathexp.h -- The shell interface to the globbing library. */
2
8868edaf 3/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
ccc6cda3
JA
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
3185942a
JA
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
ccc6cda3 11
3185942a
JA
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
ccc6cda3 16
3185942a
JA
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19*/
ccc6cda3
JA
20
21#if !defined (_PATHEXP_H_)
22#define _PATHEXP_H_
23
74091dd4
CR
24#define GLOB_FAILED(glist) (glist) == (char **)&glob_error_return
25
ccc6cda3
JA
26extern int noglob_dot_filenames;
27extern char *glob_error_return;
ccc6cda3 28
cce855bc
JA
29/* Flag values for quote_string_for_globbing */
30#define QGLOB_CVTNULL 0x01 /* convert QUOTED_NULL strings to '\0' */
31#define QGLOB_FILENAME 0x02 /* do correct quoting for matching filenames */
f1be666c 32#define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */
d233b485
CR
33#define QGLOB_CTLESC 0x08 /* turn CTLESC CTLESC into CTLESC for BREs */
34#define QGLOB_DEQUOTE 0x10 /* like dequote_string but quote glob chars */
cce855bc
JA
35
36#if defined (EXTENDED_GLOB)
f73dda09 37/* Flags to OR with other flag args to strmatch() to enabled the extended
cce855bc
JA
38 pattern matching. */
39# define FNMATCH_EXTFLAG (extended_glob ? FNM_EXTMATCH : 0)
40#else
41# define FNMATCH_EXTFLAG 0
42#endif /* !EXTENDED_GLOB */
43
95732b49 44#define FNMATCH_IGNCASE (match_ignore_case ? FNM_CASEFOLD : 0)
a0c0a00f 45#define FNMATCH_NOCASEGLOB (glob_ignore_case ? FNM_CASEFOLD : 0)
95732b49 46
ccc6cda3 47extern int glob_dot_filenames;
cce855bc 48extern int extended_glob;
3185942a 49extern int glob_star;
95732b49 50extern int match_ignore_case; /* doesn't really belong here */
ccc6cda3 51
8868edaf 52extern int unquoted_glob_pattern_p PARAMS((char *));
ccc6cda3 53
cce855bc 54/* PATHNAME can contain characters prefixed by CTLESC; this indicates
ccc6cda3 55 that the character is to be quoted. We quote it here in the style
cce855bc 56 that the glob library recognizes. If flags includes QGLOB_CVTNULL,
ccc6cda3
JA
57 we change quoted null strings (pathname[0] == CTLNUL) into empty
58 strings (pathname[0] == 0). If this is called after quote removal
cce855bc 59 is performed, (flags & QGLOB_CVTNULL) should be 0; if called when quote
ccc6cda3 60 removal has not been done (for example, before attempting to match a
cce855bc
JA
61 pattern while executing a case statement), flags should include
62 QGLOB_CVTNULL. If flags includes QGLOB_FILENAME, appropriate quoting
63 to match a filename should be performed. */
8868edaf 64extern char *quote_string_for_globbing PARAMS((const char *, int));
ccc6cda3 65
8868edaf
CR
66extern int glob_char_p PARAMS((const char *));
67extern char *quote_globbing_chars PARAMS((const char *));
ccc6cda3 68
8868edaf
CR
69/* Call the glob library to do globbing on PATHNAME. FLAGS is additional
70 flags to pass to QUOTE_STRING_FOR_GLOBBING, mostly having to do with
71 whether or not we've already performed quote removal. */
72extern char **shell_glob_filename PARAMS((const char *, int));
ccc6cda3 73
f73dda09 74/* Filename completion ignore. Used to implement the "fignore" facility of
a0c0a00f 75 tcsh, GLOBIGNORE (like ksh-93 FIGNORE), and EXECIGNORE.
ccc6cda3
JA
76
77 It is passed a NULL-terminated array of (char *)'s that must be
78 free()'d if they are deleted. The first element (names[0]) is the
79 least-common-denominator string of the matching patterns (i.e.
80 u<TAB> produces names[0] = "und", names[1] = "under.c", names[2] =
81 "undun.c", name[3] = NULL). */
82
83struct ign {
84 char *val;
85 int len, flags;
86};
87
8868edaf 88typedef int sh_iv_item_func_t PARAMS((struct ign *));
f73dda09 89
ccc6cda3 90struct ignorevar {
a0c0a00f 91 char *varname; /* FIGNORE, GLOBIGNORE, or EXECIGNORE */
ccc6cda3
JA
92 struct ign *ignores; /* Store the ignore strings here */
93 int num_ignores; /* How many are there? */
94 char *last_ignoreval; /* Last value of variable - cached for speed */
f73dda09 95 sh_iv_item_func_t *item_func; /* Called when each item is parsed from $`varname' */
ccc6cda3
JA
96};
97
8868edaf 98extern void setup_ignore_patterns PARAMS((struct ignorevar *));
ccc6cda3 99
8868edaf
CR
100extern void setup_glob_ignore PARAMS((char *));
101extern int should_ignore_glob_matches PARAMS((void));
102extern void ignore_glob_matches PARAMS((char **));
ccc6cda3
JA
103
104#endif