Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jul 2003 01:34:15 -0700
From:      David Schultz <das@FreeBSD.ORG>
To:        Luigi Rizzo <rizzo@icir.org>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: hints on shell string expansion ?
Message-ID:  <20030707083415.GB90638@HAL9000.homeunix.com>
In-Reply-To: <20030707004626.B56037@xorpc.icir.org>
References:  <20030707004626.B56037@xorpc.icir.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 07, 2003, Luigi Rizzo wrote:
> but i because the string of actions is used in several places,
> I would love to find a way to group actions into a single
> variable and then write something like this
> 
> 	actions="allow 'deny log' 'pipe 10'"
> 	for act in $actions ; do
> 		echo "add $act ip from 1.2.3.4 to 5.6.7.8"
> 	done

I've used a trick with 'set' for something similar, so perhaps
this will work for you:

	set -- allow 'deny log' 'pipe 10'
	while [ $# -gt 0 ]; do
		act=$1
		# do stuff here
		shift
	done

You can also use 'eval', but that makes escaping nasty.  It may be
possible to change the IFS to something other than space, but I've
never messed around with that particular black magic.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030707083415.GB90638>