sysctl with regex?

Garrett Cooper yanefbsd at
Wed Feb 10 00:48:00 UTC 2010

On Feb 9, 2010, at 4:19 PM, David Wolfskill wrote:

> On Tue, Feb 09, 2010 at 04:14:12PM -0800, Garrett Cooper wrote:
>> ...
>> 	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 believe it's easier to be precise about exactly what is wanted with a
> regex (vs. a glob).
> On the other hand, globs tend to be "quick & dirty" (in my experience).  ;-}

	Your doppleganger's Andrew :o?
	Regexps have a certain degree of ambiguity with them, as the following is a valid regexp:

sysctl dev\.cpu\..*\.temperature

	Assuming the correct periods are escaped, this would be a minor bug-prone task to complete.
	Whereas this form will return different results from what you want most likely (note the subtle difference with the extra period):

sysctl dev\.cpu.*\.temperature

	Globs in this case don't buy you that much difference for what you want, and (IMO) add unnecessary complexity to the problem as you can still apply basic character classes, et all.

More information about the freebsd-hackers mailing list