From owner-freebsd-rc@FreeBSD.ORG Thu Dec 1 19:27:02 2011 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36AAB106566C; Thu, 1 Dec 2011 19:27:02 +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 C31D18FC08; Thu, 1 Dec 2011 19:27:01 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id E44BF35A9F3; Thu, 1 Dec 2011 20:26:59 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id CC5E528468; Thu, 1 Dec 2011 20:26:59 +0100 (CET) Date: Thu, 1 Dec 2011 20:26:59 +0100 From: Jilles Tjoelker To: Doug Barton Message-ID: <20111201192659.GA29936@stack.nl> References: <4ED66DCB.1040102@yandex.ru> <4ED67B8F.50109@yandex.ru> <4ED6BE87.4060408@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ED6BE87.4060408@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-rc@freebsd.org, Ruslan Mahmatkhanov Subject: Re: rc-script review request X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2011 19:27:02 -0000 On Wed, Nov 30, 2011 at 03:38:47PM -0800, Doug Barton wrote: > 4. $@ should be used there instead of $* because the former treats the > elements as discrete, which is what you want to feed a for loop. This is assuming you want the arguments as separate fields right there. Variables can only contain a single field. > zope213_check_instances () { > cmd="$1" > shift > if [ -n "$@" ]; then This probably does not do what you want if $# is not 1, because of the word splitting. > zope213_instances="$@" With our sh, this is equivalent to zope213_instances="$*" but it is less portable. POSIX defines "$@" as potentially resulting in multiple words, which does not mean anything if it is in a context where word splitting is not performed. In practice, some other shells separate the arguments using a space rather than the first character of IFS. Another reason to use "$*" here is that "$*" does the same thing in contexts where word splitting occurs. > elif [ -z "$zope213_instances" ]; then > err 1 "No value for zope213_instances, so nothing to do" > fi > } -- Jilles Tjoelker