Date: Thu, 6 Jan 2005 20:09:12 -0600 From: Eric F Crist <ecrist@secure-computing.net> To: Tom Vilot <tom@vilot.com> Cc: FreeBSD-Questions Questions <freebsd-questions@freebsd.org> Subject: Re: my lame attempt at a shell script... Message-ID: <1F964093-6051-11D9-90DC-000D9333E43C@secure-computing.net> In-Reply-To: <41DDE5C5.2050402@vilot.com> References: <06DDB71C-5DB4-11D9-B56F-000D9333E43C@secure-computing.net> <8B357427-5DB7-11D9-89A5-000D93AD26C8@tntluoma.com> <Pine.NEB.4.61.9.0501041028340.407@kenmore.kozy-kabin.nl> <7B531D49-6041-11D9-8A15-000D9333E43C@secure-computing.net> <41DDE5C5.2050402@vilot.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail-1-55017107 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Jan 6, 2005, at 7:28 PM, Tom Vilot wrote: > 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 What is the point of the { } around some variables? _______________________________________________________ Eric F Crist "I am so smart, S.M.R.T!" Secure Computing Networks -Homer J Simpson --Apple-Mail-1-55017107 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iEYEARECAAYFAkHd70gACgkQRAAY9knOW+pcIQCfV7cZgNH/q+FQiTQcyjkUn41o 53kAn2K/7QfxsMZeNM+Oqcduiv7ZbZer =YfaE -----END PGP SIGNATURE----- --Apple-Mail-1-55017107--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1F964093-6051-11D9-90DC-000D9333E43C>