From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 7 00:46:27 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 022F837B401 for ; Mon, 7 Jul 2003 00:46:27 -0700 (PDT) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9AC0543FCB for ; Mon, 7 Jul 2003 00:46:26 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.8p1/8.12.3) with ESMTP id h677kQkN062744; Mon, 7 Jul 2003 00:46:26 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.8p1/8.12.3/Submit) id h677kQGe062743; Mon, 7 Jul 2003 00:46:26 -0700 (PDT) (envelope-from rizzo) Date: Mon, 7 Jul 2003 00:46:26 -0700 From: Luigi Rizzo To: hackers@freebsd.org Message-ID: <20030707004626.B56037@xorpc.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Subject: 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 07:46:27 -0000 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