[rancid] hostname glob - regex?
Alan McKinnon
alan.mckinnon at gmail.com
Sun Feb 23 15:51:39 UTC 2014
On 23/02/2014 12:04, Per-Olof Olsson wrote:
> heasley wrote 2014-02-10 18:30:
>> Mon, Feb 10, 2014 at 12:01:34AM +0100, Pawe?? Rzepa:
>>> W dniu 06.02.2014 08:44, Pawel Rzepa pisze:
>>>
>>> Hi,
>>> Any help? I've digged into this a little and found that .cloginrc is
>>> interpreted by expect. I'm not very familiar with expect, tried some
>>> regexps with braces, escaped braces etc and no success. Is it impossible
>>> to use regexp in this context?
>>
>> no; if it were, the manpage would have read regex, not glob. regex would
>> be useful; though i'm not sure how to implement it, since glob and regex
>> are not complatible. perhaps a global knob in cloginrc that switches the
>> format to regex? or an regex-specific version of the 'add' function and
>> search regexes before globs?
>>
>> Per Olaf, ideas?
>>
>
> Just replace "string match" with "regexp" will make a big format change
> in cloginrc.
I would strongly recommend not implementing regexp in .cloginrc:
- regexps are heard to read and hard to debug
- users can apply them in a needlessly overcomplicated fashion
- when a regexp that describes a general case is early in the list and a
more specific match is later, the first match wins and this is really
really hard to debug, simply because there's no log to say which line in
.cloginrc was matched.
The principle use case for regexps over globs seems to be the |
operator, something like this:
add username 192.168.(0|1|2|3|4).* {username1}
add username 192.168.* {username2}
The first line can always be expanded to 5 individual lines with the
current syntax - less verbose but more explicit and fewer mistakes.
--
Alan McKinnon
alan.mckinnon at gmail.com
More information about the Rancid-discuss
mailing list