rc-script review request
Jilles Tjoelker
jilles at stack.nl
Thu Dec 1 19:27:02 UTC 2011
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
More information about the freebsd-rc
mailing list