From owner-svn-src-head@FreeBSD.ORG Wed Dec 19 21:10:15 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5CE014C5; Wed, 19 Dec 2012 21:10:15 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9A4CC8FC0A; Wed, 19 Dec 2012 21:10:13 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so1898943lah.27 for ; Wed, 19 Dec 2012 13:10:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=fUt08Oiq5Sqv9g4vAy37oxmQtD/oW0djGSdJK0wIjbI=; b=tnyB6XVRUXAJK9f5epLL/q9nXEg8HXqIZWXn1mE324jrnDxarl6OH0MUec1CeqfVP4 c5Kh2tg8FsexUr6oWCVSOIXN1gj8Pv44ftGynmGgTJEM1W7sbnUjPE9Dy8YCYtQQLg7k u7dCDhnZIbK23ly43EqxPGSM75kHmyDz6hHIfLr4N+b+jMoGQSab7pJBuaQUcq86ATIf RSJAPmvOUukhWgQNQOSkxT0iPbzJ5unlsAP/Bj1FCoYq/Ebfpe4Pu17epJeL3khe7plN Pk969aFqnUmu3jRdi5deDyhCk1Os5vzpcpV9hc/re2llXRPQwIxv9i/sxviQ4ky1ESM9 9ttw== MIME-Version: 1.0 Received: by 10.112.29.104 with SMTP id j8mr2968990lbh.0.1355951406791; Wed, 19 Dec 2012 13:10:06 -0800 (PST) Received: by 10.112.99.70 with HTTP; Wed, 19 Dec 2012 13:10:06 -0800 (PST) In-Reply-To: <20121219210418.GA83983@stack.nl> References: <201212132332.qBDNWmK4037503@svn.freebsd.org> <50D1D720.80206@FreeBSD.org> <1355931456.1198.203.camel@revolution.hippie.lan> <05CC5BAD-B968-4A7A-8097-A3344D970D63@mu.org> <1355932607.1198.206.camel@revolution.hippie.lan> <50D2128A.7030205@delphij.net> <20121219210418.GA83983@stack.nl> Date: Wed, 19 Dec 2012 13:10:06 -0800 Message-ID: Subject: Re: svn commit: r244198 - in head: etc/rc.d sbin/sysctl From: Garrett Cooper To: Jilles Tjoelker Content-Type: text/plain; charset=ISO-8859-1 Cc: Ian Lepore , "src-committers@freebsd.org" , d@delphij.net, "svn-src-all@freebsd.org" , Alfred Perlstein , Xin LI , "svn-src-head@freebsd.org" , Andrey Zonov X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2012 21:10:15 -0000 On Wed, Dec 19, 2012 at 1:04 PM, Jilles Tjoelker wrote: > On Wed, Dec 19, 2012 at 11:16:26AM -0800, Xin Li wrote: >> It may be worthy to make sysctl(8) to accept mutiple -f's, but it >> seems to be hard to write shell scripts that utilizes this feature in >> a elegant manner. > > This is possible but indeed a bit ugly. > > Hard-coding the list of files is not too bad: > > shift $# > for _f in /etc/sysctl.d/* /etc/sysctl.conf /etc/sysctl.conf.local; do > [ -r "$_f" ] && set -- "$@" -f "$_f" > done > sysctl "$@" > > If the list is passed in the positional parameters it becomes uglier: > > _first=1 > for _f do > [ -n "$_first" ] && shift $# > _first= > [ -r "$_f" ] && set -- "$@" -f "$_f" > done > sysctl "$@" > > This uses for's temporary storage of the words being iterated over, > building a new set of positional parameters in the loop. > > An alternative is to append the new list to the old one and to use a > saved copy of $# to remove the old elements afterwards. > > It would be nice to store the arguments in a variable but that is not > possible because all characters are valid in pathnames, except the null > character which cannot be used in shell either. find -exec / echo | xargs ? Seems like there's a better way to solve this. Thanks, -Garrett