On September 27, 2021 5:38 PM, Jeff King wrote:
Subject: Re: [PATCH] config: add an includeIf.env{Exists,Bool,Is,Match}
On Mon, Sep 27, 2021 at 04:53:59PM -0400, Randall S. Becker wrote:
quoted
What about something like:
[includeIf "env:PATH ~= '^(.*😊)/usr/bin(:.*)*$' "]
Using single quotes and a full regex pattern instead of trying to
provide a syntax to extract a pattern and then match. One call to
regexec() would be easier. Then escaping is regcomp's problem
(mostly). Potentially, you could even remove the outer ", but that
would be wonky. You could omit the ^ and $ by default assuming a full
match.
I almost suggested that, but then...how do you put single-quotes in your pattern? You can backslash-escape them, but:
- do you need to escape the backslash to get it through the config
parser intact?
- it seems extra funny to me because single quotes usually imply a
lack of interpolation
Exactly so. I think it would be more clear to have a regular expression be provided literally without interpretation other than by regcomp - other than the emergency ' escape, of course.