From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 10 00:14:16 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 8A7E710656D7 for ; Wed, 10 Feb 2010 00:14:16 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: from mail-yx0-f172.google.com (mail-yx0-f172.google.com [209.85.210.172]) by mx1.freebsd.org (Postfix) with ESMTP id 3E4BA8FC08 for ; Wed, 10 Feb 2010 00:14:16 +0000 (UTC) Received: by yxe2 with SMTP id 2so7136948yxe.7 for ; Tue, 09 Feb 2010 16:14:15 -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=XO5a11/sDyKfvypOJj8IO4P2HOXvR/pAMMmn7T430As=; b=xFea3kCPc+lBEzIg+NR+k/uNaEkao21iSFGrvyEmgrIi10+FfLzzqwoRvjWtNKCGQv juRY4tSl0toqHCTKNm3Hc8faICfSsDsn/ku54W0dnomfK+tDVmOF7Hz7VCuhXH4ljBS3 VRg39u0OE/ZmuDkFUHm9pzB/d6Evc0c5CeaIM= 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=hCRy+EW1BHgGArg9q0taSrbmBzRovgQ5eNuclWDvCYZZ5N9zITk4TCIXsKF+NcypLD kWlO7Qt9c1W8vJjeVQLTCA85T/p2O+6MpC/W3sh7TQsdLn4BNXMe/Fw+XBLXOEF63S3n ACR4jGXqNIyRqAZMYaNShfbeVAwo/q0qjJB+Y= Received: by 10.100.1.10 with SMTP id 10mr5317720ana.242.1265760855468; Tue, 09 Feb 2010 16:14:15 -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 16sm396296gxk.7.2010.02.09.16.14.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Feb 2010 16:14:14 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=iso-8859-1 From: Garrett Cooper In-Reply-To: Date: Tue, 9 Feb 2010 16:14:12 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <26049703-8844-4476-B277-776A4EFC0A53@gmail.com> References: <86tytqvwky.fsf@ds4.des.no> 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:14:16 -0000 On Feb 9, 2010, at 3:28 PM, Andrew Brampton wrote: > 2010/2/9 Dag-Erling Sm=F8rgrav : >> Andrew Brampton writes: >>> Today I was writing a script to read all the dev.cpu.?.temperature >>> sysctl OIDs. I was parsing them using a simple grep, but it occurred >>> to me it might be better if sysctl supported some form of regexp. >>=20 >> You mean glob, not regexp... >=20 > Could you explain why do I mean glob instead or regexp? > Is glob simple matches, ie * and ? > and regexp more complex like [a-z]* 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. >>> For example instead of typing: >>> sysctl -a | grep dev.cpu.*.temperature >>>=20 >>> I could write: >>> sysctl dev.cpu.*.temperature >>=20 >> Sounds like a good idea. Shouldn't be too hard to implement either. >=20 > If I get time I might submit a patch. 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). Thanks, -Garrett=