sysctl with regex?
Garrett Cooper
yanefbsd at gmail.com
Wed Feb 10 00:51:15 UTC 2010
On Feb 9, 2010, at 4:45 PM, Andrew Brampton wrote:
> On Wed, Feb 10, 2010 at 12:14 AM, Garrett Cooper <yanefbsd at gmail.com> wrote:
>> C-shell globs as some programming languages referring to it as, i.e. perl (which this is a subset of the globs concept) allow for expansion via `*' to be `anything'. Regexp style globs for what you're looking for would be either .* (greedy) or .+ (non-greedy), with it being most likely the latter case.
>>
>
> Ah I understand the difference now. Thanks.
>
>> I'll see if I can whip up a quick patch in the next day or so -- but before I do that, does it make more sense to do globs or regular expressions? There are pluses and minuses to each version and would require some degree of parsing (and potentially escaping).
>
> I think going for the simpler glob option might be best. In my earlier
> example a regex would have problems with all the periods, would it
> not? Also if I want to match anything I would always forget to write
> .* instead of just *
Yes -- that's a part of the ambiguity in standard regular expressions that I was implying...
> I was just having a quick look at how to implement this, would it be
> best to use the fnmatch function? Having a quick browse of the FreeBSD
> source I found csh_match in /usr.sbin/pkg_install/lib/match.c:L456
> which seems to do something similar to what we want.
fnmatch is for matching filenames... I think there's a better way to do it with globs, but I'll have to take a quick peek at python's glob module so I don't reinvent the wheel (using fnmatch(3) // glob(3) to string match seems kind of stupid to do...).
> BTW Feel free to implement this, I was going to have a go but I doubt
> I'd actually get around to it :(
Ok..
Thanks,
-Garrett
More information about the freebsd-hackers
mailing list