RE: [PATCH] config: add an includeIf.env{Exists,Bool,Is,Match}

From
Randall S. Becker <hidden>
Date
2021-09-27 21:56:43
Reply to
Jeff King, 2021-09-27
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.
Thread (10 messages) 10 messages, 4 authors, last reply 2021-09-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help