Date: Mon, 17 Dec 2012 13:50:04 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Xin LI <delphij@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r244198 - in head: etc/rc.d sbin/sysctl Message-ID: <20121217125004.GA47894@stack.nl> In-Reply-To: <201212132332.qBDNWmK4037503@svn.freebsd.org> References: <201212132332.qBDNWmK4037503@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121217125004.GA47894>