From 75cdabaf13ed45bbf45db8761c6dcbad0e720d0d Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:24:51 +0800 Subject: [PATCH] Relax syntax mapping rule restrictions to allow brace expansion --- build/syntax_mapping.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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); /// /// 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 { @@ -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}""#); }