Date: Thu, 1 Dec 2011 20:26:59 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Doug Barton <dougb@FreeBSD.org> Cc: freebsd-rc@freebsd.org, Ruslan Mahmatkhanov <cvs-src@yandex.ru> Subject: Re: rc-script review request Message-ID: <20111201192659.GA29936@stack.nl> In-Reply-To: <4ED6BE87.4060408@FreeBSD.org> References: <4ED66DCB.1040102@yandex.ru> <CADLo83-RR945MKbdvpdghHsHpO1_MA4OA21WkA_3xCTjOOhDsQ@mail.gmail.com> <4ED67B8F.50109@yandex.ru> <4ED6BE87.4060408@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111201192659.GA29936>
