From owner-svn-src-all@FreeBSD.ORG Mon Dec 17 12:50:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D4B5369B; Mon, 17 Dec 2012 12:50:06 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 6D1108FC12; Mon, 17 Dec 2012 12:50:05 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 9A7DA358C58; Mon, 17 Dec 2012 13:50:04 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 875072848C; Mon, 17 Dec 2012 13:50:04 +0100 (CET) Date: Mon, 17 Dec 2012 13:50:04 +0100 From: Jilles Tjoelker To: Xin LI Subject: Re: svn commit: r244198 - in head: etc/rc.d sbin/sysctl Message-ID: <20121217125004.GA47894@stack.nl> References: <201212132332.qBDNWmK4037503@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201212132332.qBDNWmK4037503@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2012 12:50:06 -0000 On Thu, Dec 13, 2012 at 11:32:48PM +0000, Xin LI wrote: > Author: delphij > Date: Thu Dec 13 23:32:47 2012 > New Revision: 244198 > URL: http://svnweb.freebsd.org/changeset/base/244198 > Log: > Teach sysctl(8) about parsing a file (while I'm there also give it > capability of parsing both = and : formats). > Submitted by: hrs (initial version, bugs are mine) > MFC after: 3 months > Modified: head/sbin/sysctl/sysctl.c > ============================================================================== > --- head/sbin/sysctl/sysctl.c Thu Dec 13 23:19:13 2012 (r244197) > +++ head/sbin/sysctl/sysctl.c Thu Dec 13 23:32:47 2012 (r244198) > [snip] > @@ -194,6 +213,14 @@ parse(const char *string) > } > while (isspace(*cp)) > cp++; > + /* Strip a pair of " or ' if any. */ > + switch (*cp) { > + case '\"': > + case '\'': > + if (cp[strlen(cp) - 1] == *cp) > + cp[strlen(cp) - 1] = '\0'; > + cp++; > + } > newval = cp; > newsize = strlen(cp); > } As I wrote in http://lists.freebsd.org/pipermail/freebsd-current/2012-December/038241.html I think this is messy, and requires a confusing change to user code that called sysctl(8) with strings starting with a quote. On the positive side this allows setting sysctl values starting with whitespace, but perhaps the isspace loop above it should be removed as well so that can be done without adding quotes. It seems inappropriate for sysctl.conf in particular since that file did not allow the extra whitespace in the first place. -- Jilles Tjoelker