From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 7 05:09:31 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 A878937B401 for ; Mon, 7 Jul 2003 05:09:31 -0700 (PDT) Received: from mail.rdslink.ro (mail.rdslink.ro [193.231.236.20]) by mx1.FreeBSD.org (Postfix) with SMTP id D97A443FB1 for ; Mon, 7 Jul 2003 05:09:29 -0700 (PDT) (envelope-from enache@rdslink.ro) Received: (qmail 12845 invoked from network); 7 Jul 2003 12:03:27 -0000 Received: from unknown (HELO ratsnest.hole) (10.100.0.70) by mail.rdslink.ro with SMTP; 7 Jul 2003 12:03:27 -0000 Date: Mon, 7 Jul 2003 15:14:00 +0300 From: Enache Adrian To: Luigi Rizzo Message-ID: <20030707121400.GA1262@ratsnest.hole> 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> User-Agent: Mutt/1.4i 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 12:09:31 -0000 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 Regards, Adi