Add a way to disable sequence matching
S: wontfixT: feature
I'm [writing a specification](https://github.com/fsfe/reuse-docs/pull/133) that needs a very, very, very simple globbing of paths, and I am writing a tool that implements the specification. The globbing needs to:
- Always use POSIX paths.
- Match zero or more characters with `*`, including `.` at the start of a file, excluding path separators.
- Match zero or more characters with `**`, including `.` at the start of a file, including path separators.
- Escape characters with `\`.
Using `DOTGLOB | FORCEUNIX | GLOBSTAR` in wcmatch, I am like 99% of the way there, which is great! Less work for me, and this library looks amazing.
However, wcmatch comes with two more features that I do not need:
- `?` matches a single character.
- `[seq]` and `[!seq]` matches any character in the sequence.
I am not well bothered by `?`—I do not need it, but I can add it to the specification without much fuss. Being able to turn this off would be nice, but it is not needed.
`[seq]` is far too feature-rich for me to use, however. I do not want to include this in the specification. But if I do not include this in the specification, then my tool must subsequently not implement this. I have considered using a pre-parser to escape all square brackets, but I figured an upstream-first approach would be helpful.
I would love a `NOSEQ` flag that disables the behaviour I do not need.
---
Additional context:
This is being discussed in [this thread in a PR](https://github.com/fsfe/reuse-docs/pull/133#discussion_r1450629582). Copying my available options from that thread:
> 1. Open an issue against wcmatch and plead them to include an option to turn this behaviour off. Or do this ourselves—I can write Python!
> 2. Do a bad job of documenting this. See: the referenced code.
> 3. Don't document it at all. This isn't great.
> 4. Do a good job of documenting this. But: that's a loooot of words spent on a feature _we don't even want_.
> 5. Make an attempt at turning this behaviour off downstream. Whenever we see `[` or `]`, escape that character internally in the REUSE tool, and the seq behaviour will never be triggered. Subsequently, we needn't document this. But: this may have unintended consequences, maybe. I'm not sure.
The relevant bit of the specification is fairly simple. There is a `REUSE.toml` configuration file that matches path expressions against existing files in a project, and applies metadata to those matched files. For example:
```toml
[[annotations]]
path = "**/*.md"
SPDX-License-Identifier = "CC-BY-4.0"
```
This matches all Markdown files and asserts that they are all licensed under CC-BY-4.0. Super simple, easy peasy, no fancy features needed.
关闭于 2024-04-28 6 条评论