Date: Mon, 7 Jul 2003 15:14:00 +0300 From: Enache Adrian <enache@rdslink.ro> To: Luigi Rizzo <rizzo@icir.org> Cc: hackers@freebsd.org Subject: Re: hints on shell string expansion ? Message-ID: <20030707121400.GA1262@ratsnest.hole> 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 at 12:46:26AM -0700, Luigi Rizzo wrote: > 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 Isn't this what you want ? $ set allow "deny log" "pipe 10" $ for act in "$@"; do echo "<$act>"; done <allow> <deny log> <pipe 10> Regards, Adi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030707121400.GA1262>