summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Peter <sharkdp@users.noreply.github.com>2024-02-23 21:52:55 +0100
committerGitHub <noreply@github.com>2024-02-23 21:52:55 +0100
commite6e8f847be605b9b4f790a3891c7ea27bdd1fb1d (patch)
treea642a7b63d6b05e865993dc46b8cf59b33e1a070
parent3ffa3648cf162853e7c1494c72f442c260649651 (diff)
parentb9e249f782bdbbe587067356f12b38319b72cd1e (diff)
Merge pull request #2865 from cyqsimon/syntax-mapping-fix
Relax syntax mapping rule restrictions to allow brace expansion
-rw-r--r--CHANGELOG.md1
-rw-r--r--build/syntax_mapping.rs12
2 files changed, 8 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7498b412..e5d0375f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@
- Pull in fix for unsafe-libyaml security advisory, see #2812 (@dtolnay)
- Update git-version dependency to use Syn v2, see #2816 (@dtolnay)
- Update git2 dependency to v0.18.2, see #2852 (@eth-p)
+- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon)
- Apply clippy fixes #2864 (@cyqsimon)
## Syntaxes
diff --git a/build/syntax_mapping.rs b/build/syntax_mapping.rs
index 959caea8..91a448f6 100644
--- a/build/syntax_mapping.rs
+++ b/build/syntax_mapping.rs
@@ -53,14 +53,16 @@ struct Matcher(Vec<MatcherSegment>);
///
/// Note that this implementation is rather strict: it will greedily interpret
/// every valid environment variable replacement as such, then immediately
-/// hard-error if it finds a '$', '{', or '}' anywhere in the remaining text
-/// segments.
+/// hard-error if it finds a '$' anywhere in the remaining text segments.
///
/// The reason for this strictness is I currently cannot think of a valid reason
-/// why you would ever need '$', '{', or '}' as plaintext in a glob pattern.
-/// Therefore any such occurrences are likely human errors.
+/// why you would ever need '$' as plaintext in a glob pattern. Therefore any
+/// such occurrences are likely human errors.
///
/// If we later discover some edge cases, it's okay to make it more permissive.
+///
+/// Revision history:
+/// - 2024-02-20: allow `{` and `}` (glob brace expansion)
impl FromStr for Matcher {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -106,7 +108,7 @@ impl FromStr for Matcher {
if non_empty_segments
.iter()
.filter_map(Seg::text)
- .any(|t| t.contains(['$', '{', '}']))
+ .any(|t| t.contains('$'))
{
bail!(r#"Invalid matcher: "{s}""#);
}