Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jul 2003 00:46:26 -0700
From:      Luigi Rizzo <rizzo@icir.org>
To:        hackers@freebsd.org
Subject:   hints on shell string expansion ?
Message-ID:  <20030707004626.B56037@xorpc.icir.org>

next in thread | raw e-mail | index | archive | help
Hi,
i need a bit of help from creative /bin/sh users...

I am writing a script to generate ipfw test cases, and as
part of the script i need to generate 'actions' which can be either
one or more, e.g.

a1="allow"
a2="deny log"
a3="pipe 10"

Now, this works:

	for act in "$a1" "$a2" "$a3"; do
		echo "add $act ip from 1.2.3.4 to 5.6.7.8"
	done

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 have tried to play tricks with quotes and backquotes, backslashes,
eval, etc. but no methods helped. Any ideas ?

	cheers
	luigi



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