From owner-freebsd-questions@FreeBSD.ORG Fri Jan 7 01:28:40 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6182F16A4CE for ; Fri, 7 Jan 2005 01:28:40 +0000 (GMT) Received: from fusion.vilot.net (vilot.com [64.246.32.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1225443D3F for ; Fri, 7 Jan 2005 01:28:40 +0000 (GMT) (envelope-from tom@vilot.com) Received: from [192.168.1.105] (c-24-8-184-241.client.comcast.net [24.8.184.241]) (authenticated bits=0) by fusion.vilot.net (8.13.1/8.12.9) with ESMTP id j071Pai4041046; Thu, 6 Jan 2005 19:25:36 -0600 (CST) (envelope-from tom@vilot.com) Message-ID: <41DDE5C5.2050402@vilot.com> Date: Thu, 06 Jan 2005 18:28:37 -0700 From: Tom Vilot User-Agent: Mozilla Thunderbird 1.0 (X11/20041222) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Eric F Crist References: <06DDB71C-5DB4-11D9-B56F-000D9333E43C@secure-computing.net> <8B357427-5DB7-11D9-89A5-000D93AD26C8@tntluoma.com> <7B531D49-6041-11D9-8A15-000D9333E43C@secure-computing.net> In-Reply-To: <7B531D49-6041-11D9-8A15-000D9333E43C@secure-computing.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: "Colin J. Raven" cc: Timothy Luoma cc: FreeBSD-Questions Questions Subject: Re: my lame attempt at a shell script... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jan 2005 01:28:40 -0000 Eric F Crist wrote: > > First off, thanks again for all the help you've offered thus far. > That being said, I'm having a problem with variables in a function. > The code I'm having a problem with is: > > setup_loopback () { > ${fwcmd} add ${rulenum1} pass all from any to any via lo0; > ${rulenum1}=`expr $rulenum1 + 50` > ${fwcmd} add ${rulenum1} deny all from any to 127.0.0.0/8; > ${rulenum1}=`expr $rulenum1 + 50` > ${fwcmd} add ${rulenum1} deny ip from 127.0.0.0/8 to any; > ${rulenum1}=`expr $rulenum1 + 50` > } > > The output of this, when run, is: > > 00050 allow ip from any to any via lo0 > 50=100: not found > 00050 deny ip from any to 127.0.0.0/8 > 50=100: not found > 00050 deny ip from 127.0.0.0/8 to any > 50=100: not found > > This tells me that it's doing the math correctly, but it's not > reassigning the calculated value back to the variable. > > Any pointers? this is a very common mistake and is one of those things about sh and bash that drives me batty, too. You're thinking like perl. :c) Stripping it down to a test script, I have this: ----- rulenum=50 rulenum=`$rulenum + 50` echo $rulenum ---- I believe that is what you are after. When you *assign* you don't use $