From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 10 00:51:14 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7752106566C for ; Wed, 10 Feb 2010 00:51:14 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: from mail-yw0-f184.google.com (mail-yw0-f184.google.com [209.85.211.184]) by mx1.freebsd.org (Postfix) with ESMTP id 7B8BE8FC15 for ; Wed, 10 Feb 2010 00:51:14 +0000 (UTC) Received: by ywh14 with SMTP id 14so814635ywh.28 for ; Tue, 09 Feb 2010 16:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-type:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to:x-mailer; bh=l90Ak3+M5FArLjR+K9NMJqUhPZqx3tae6lV8mYNXJoc=; b=DK8LX8rcREFmxYTrBXbgrxzd+gc2wk9l+kHbQDiKVjZwQ+Kyq9vdUMndjKg7lCSPN4 i4XKMi0fgPHfz1/a6zCcxmY3CpTbKy5lNR+r6Oy5NEakN4Ip6hDQUCIt47bnEEiC7fau AFhn8LDRmadkoovX/1/GGGUjMv3hWqJ0H94xs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=wBoZaa0YQrSUH9VmeAesZpjWyY5OWkOJRyDaiWY0CkC3QozM3rGY7baPepA8UhcCNF CsUuNHpn/ekXWocW94Vs/tN/ckWB52+NTFuHMKM4ZviLrZJf64mY/gmAA6ARse43T4ow Rid0KDY+WUUtzaH8Bc//aBH6ZEN504q5qIVxk= Received: by 10.101.2.4 with SMTP id e4mr9617201ani.49.1265763073389; Tue, 09 Feb 2010 16:51:13 -0800 (PST) Received: from dhcp-173-37-1-138.cisco.com (nat.ironport.com [63.251.108.100]) by mx.google.com with ESMTPS id 16sm421170gxk.3.2010.02.09.16.51.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Feb 2010 16:51:12 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: Garrett Cooper In-Reply-To: Date: Tue, 9 Feb 2010 16:51:09 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <7BE25339-9614-4E64-BA14-85291B5DE356@gmail.com> References: <86tytqvwky.fsf@ds4.des.no> <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> To: Andrew Brampton X-Mailer: Apple Mail (2.1077) Cc: =?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?= , freebsd-hackers@freebsd.org Subject: Re: sysctl with regex? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2010 00:51:15 -0000 On Feb 9, 2010, at 4:45 PM, Andrew Brampton wrote: > On Wed, Feb 10, 2010 at 12:14 AM, Garrett Cooper = 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=