hints on shell string expansion ?
das at FreeBSD.ORG
Mon Jul 7 01:34:26 PDT 2003
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 188.8.131.52 to 184.108.40.206"
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
# do stuff here
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.
More information about the freebsd-hackers