Date: Tue, 9 Feb 2010 16:51:09 -0800 From: Garrett Cooper <yanefbsd@gmail.com> To: Andrew Brampton <brampton+freebsd@gmail.com> Cc: =?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?= <des@des.no>, freebsd-hackers@freebsd.org Subject: Re: sysctl with regex? Message-ID: <7BE25339-9614-4E64-BA14-85291B5DE356@gmail.com> In-Reply-To: <d41814901002091645w289aa894q4a06cbaed59eea05@mail.gmail.com> References: <d41814901002091308s7e894b55p880bde165bbbe703@mail.gmail.com> <86tytqvwky.fsf@ds4.des.no> <d41814901002091528i4884987cmb7347dfe4d50bdc5@mail.gmail.com> <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> <d41814901002091645w289aa894q4a06cbaed59eea05@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Feb 9, 2010, at 4:45 PM, Andrew Brampton wrote: > On Wed, Feb 10, 2010 at 12:14 AM, Garrett Cooper <yanefbsd@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. >>=20 >=20 > Ah I understand the difference now. Thanks. >=20 >> 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). >=20 > 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=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7BE25339-9614-4E64-BA14-85291B5DE356>