aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual.cli54
-rw-r--r--libbuild2/parser.cxx2
-rw-r--r--tests/name/pattern.testscript12
3 files changed, 52 insertions, 16 deletions
diff --git a/doc/manual.cli b/doc/manual.cli
index d525494..bd06809 100644
--- a/doc/manual.cli
+++ b/doc/manual.cli
@@ -3422,10 +3422,14 @@ x = name@value # pairs
x = # start of a comment
\
-The complete set of syntax characters is \c{$(){\}[]@#} plus space and tab.
-Additionally, \c{*?} will be treated as wildcards in a name pattern. If
-instead we need these characters to appear literally as part of the value,
-then we either have to \i{escape} or \i{quote} them.
+The complete set of syntax characters is \c{$(){\}@#\"'} plus space and tab as
+well as \c{[]} but only in certain contexts (see \l{#attributes Attributes}
+for details). If instead we need these characters to appear literally as part
+of the value, then we either have to \i{escape} or \i{quote} them.
+
+\N|Additionally, \c{*?[} will be treated as wildcards in name patterns. Note
+that this treatment can only be inhibited with quoting and not escaping. See
+\l{#name-patterns Name Patterns} for details.|
To escape a special character, we prefix it with a backslash (\c{\\}; to
specify a literal backslash double it). For example:
@@ -3454,7 +3458,7 @@ line two
line three'
\
-Since quote characters are now also part of the syntax, if you need to specify
+Since quote characters are also part of the syntax, if you need to specify
them literally in the value, then they will either have to be escaped or
quoted. For example:
@@ -4317,6 +4321,11 @@ the number of jobs to perform in parallel, the stack size, queue depths, etc.
See the \l{b(1)} man pages for details.
+\h1#attributes|Attributes|
+
+\N{This chapter is a work in progress and is incomplete.}
+
+
\h1#name-patterns|Name Patterns|
For convenience, in certain contexts, names can be generated with shell-like
@@ -4348,11 +4357,29 @@ pat = 'foo*bar'
./: cxx{'foo*bar'}
\
-The following characters are wildcards:
+The following wildcards are recognized:
\
-* - match any number of characters (including zero)
-? - match any single character
+* - match any number of characters (including zero)
+? - match any single character
+[...] - match a character with a bracket expression
+\
+
+\N|Currently only literal character and range bracket expressions are
+supported. Specifically, no character or equivalence classes, etc., are
+supported nor the special characters backslash-escaping. See the \"Pattern
+Matching Notation\" section in the POSIX \"Shell Command Language\"
+specification for details.|
+
+Note that some wildcard characters may have special meaning in certain
+contexts. For instance, \c{[} at the beginning of a value will be interpreted
+as the start of the attribute list while \c{?} in the eval context is part of
+the ternary operator. In such cases the wildcard character will have to be
+escaped, for example:
+
+\
+x = \[1-9]-foo.txt
+y = (foo.\?xx)
\
If a pattern ends with a directory separator, then it only matches
@@ -4360,12 +4387,11 @@ directories. Otherwise, it only matches files. Matches that start with a dot
(\c{.}) are automatically ignored unless the pattern itself also starts with
this character.
-In addition to the above wildcard characters, \c{**} and \c{***} are
-recognized as wildcard character sequences. If a pattern contains \c{**}, then
-it is matched just like \c{*} but in all the subdirectories, recursively, but
-excluding directories that contain the \c{.buildignore} file. The \c{***}
-wildcard behaves like \c{**} but also matches the start directory itself. For
-example:
+In addition to the above wildcards, \c{**} and \c{***} are recognized as
+wildcard sequences. If a pattern contains \c{**}, then it is matched just like
+\c{*} but in all the subdirectories, recursively, but excluding directories
+that contain the \c{.buildignore} file. The \c{***} wildcard behaves like
+\c{**} but also matches the start directory itself. For example:
\
exe{hello}: cxx{**} # All C++ source files recursively.
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 26df3fa..f79f80e 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -3612,7 +3612,7 @@ namespace build2
tt == type::lparen ||
tt == type::lcbrace))
fail (t) << "whitespace required after attributes" <<
- info << "add an empty attribute list if this is a wildcard pattern";
+ info << "use the '\\[' escape sequence if this is a wildcard pattern";
return make_pair (has, l);
}
diff --git a/tests/name/pattern.testscript b/tests/name/pattern.testscript
index 68c6745..ac8ee10 100644
--- a/tests/name/pattern.testscript
+++ b/tests/name/pattern.testscript
@@ -129,7 +129,17 @@ EOI
$* <'print {*.txt -f*.txt +*x.txt}' >'fox.txt' : include-exclude-order
touch foo.txt;
- $* <'print {+foo.txt} {+bar.txt}' >'foo.txt' : non-wildcard
+ $* <'print {+foo.txt} {+bar.txt}' >'foo.txt' : non-wildcard
+}
+
+: escaping
+:
+{
+ touch foo.txt;
+ $* <'print \[fgh]oo.txt' >'foo.txt' : bracket
+
+ touch true1.txt;
+ $* <'print (true\?.txt') >'true1.txt' : question
}
: target-type