From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 7 01:34:26 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CCA637B413 for ; Mon, 7 Jul 2003 01:34:21 -0700 (PDT) Received: from HAL9000.homeunix.com (ip114.bella-vista.sfo.interquest.net [66.199.86.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6363B43FA3 for ; Mon, 7 Jul 2003 01:34:20 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.9) with ESMTP id h678YGK5090757; Mon, 7 Jul 2003 01:34:16 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.9/Submit) id h678YF39090756; Mon, 7 Jul 2003 01:34:15 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Mon, 7 Jul 2003 01:34:15 -0700 From: David Schultz To: Luigi Rizzo Message-ID: <20030707083415.GB90638@HAL9000.homeunix.com> Mail-Followup-To: Luigi Rizzo , hackers@freebsd.org References: <20030707004626.B56037@xorpc.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030707004626.B56037@xorpc.icir.org> cc: hackers@FreeBSD.ORG Subject: Re: hints on shell string expansion ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jul 2003 08:34:26 -0000 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.