From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 10 00:45:32 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 4DF91106566C for ; Wed, 10 Feb 2010 00:45:32 +0000 (UTC) (envelope-from brampton@gmail.com) Received: from mail-fx0-f224.google.com (mail-fx0-f224.google.com [209.85.220.224]) by mx1.freebsd.org (Postfix) with ESMTP id D12768FC13 for ; Wed, 10 Feb 2010 00:45:31 +0000 (UTC) Received: by fxm24 with SMTP id 24so105871fxm.3 for ; Tue, 09 Feb 2010 16:45:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=CnUVma0xuVgD2f4jTv2uyw1YIg2wxlI6++Ppw1v9SUk=; b=gvpl8OqcBDdDYHfcQJtEXwo7NrF5JznPFL48302GXXKCqRHPKQ4rNMSYiEQVvRKNqL yuj1mmTRslsveLsYfjtqZ3Z+7hDgCbAGvdqTRlyDN4cUSDzGU4imRnmrvmjf3I1dBV8d ha9B3qAjjUpywVj3Oh456YFx932m1UF9BP2lY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=fWmlmLZ7tY7/XVV5arEPB2oh5ZSDE6V4YYo3X33lV55575AFvDBhxnCf76RMBlsePi kc9bCyrkduKnn5QW90m5HOn449dhktNeKJ8QKQXUBcA9JpHNL2Ma2RRmyhH8r8FvTqNY xm+Q2NennTcvQa3IoCvfS6YgOtabCbZWkAp6c= MIME-Version: 1.0 Sender: brampton@gmail.com Received: by 10.223.5.81 with SMTP id 17mr5004802fau.3.1265762730635; Tue, 09 Feb 2010 16:45:30 -0800 (PST) In-Reply-To: <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> References: <86tytqvwky.fsf@ds4.des.no> <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> Date: Wed, 10 Feb 2010 00:45:30 +0000 X-Google-Sender-Auth: 17827099671df849 Message-ID: From: Andrew Brampton To: Garrett Cooper Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: =?UTF-8?Q?Dag=2DErling_Sm=C3=B8rgrav?= , 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:45:32 -0000 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 e= ither .* (greedy) or .+ (non-greedy), with it being most likely the latter = case. > Ah I understand the difference now. Thanks. > =C2=A0 =C2=A0 =C2=A0 =C2=A0I'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 glob= s 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