sysctl with regex?

Andrew Brampton brampton+freebsd at gmail.com
Wed Feb 10 00:45:32 UTC 2010


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 *

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.

BTW Feel free to implement this, I was going to have a go but I doubt
I'd actually get around to it :(

Andrew


More information about the freebsd-hackers mailing list