Re: [PATCH] config: add an includeIf.env{Exists,Bool,Is,Match}
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 27, 2021, 16:30 UTC
- Message-ID
- <xmqqo88eq8um.fsf@gitster.g>
- In-Reply-To
- <YU5KOpGkS5sH4iFJ@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
>> > Should we allow whitespace around key names and values? E.g.: >> > >> > [includeIf "env: FOO: bar"] >> > >> > is IMHO more readable (even more so if we had infix operators like >> > "=="). >> >> This asserts what? FOO=" bar"? > > Whoops, that should have been "envIs", asserting that $FOO contains > "bar".
Oh, "can we check with a literal with leading whitespace?" was what my question was about ;-)
Show 7 quoted lines
> As I said, I think it matters more with the infix operators, as: > > [includeIf "env:FOO == bar"] > > is more readable than: > > [includeIf "env:FOO==bar"]
Sure, but at that point, we'd probably want some quoting mechanism for the literal to be compared, e.g.
[includeIf "env:PATH ~= \"(:|^)/usr/bin(:|$)\""]
Show 7 quoted lines
> But I do think: > > [includeIf "envIs:FOO:bar"] > > is harder to read than even: > > [includeIf "envIs:FOO: bar"]
Hmph, that's quite subjective, I am afraid. When I see the latter in the configuration file, "do I have to have a single space before 'bar' in the value of $FOO" would be the first question that would come to my mind.
With an understanding that our syntax is so limited that we cannot even write '=' and need to resort to Is: instead, I'd actually find that the former less confusing than the latter.
Thanks.