Date: Mon, 3 Jan 2005 16:55:27 -0500 From: Timothy Luoma <lists@tntluoma.com> To: Erik Norgaard <norgaard@locolomo.org> Cc: FreeBSD-Questions Questions <freebsd-questions@freebsd.org> Subject: Re: my lame attempt at a shell script... Message-ID: <2DF07A46-5DD2-11D9-89A5-000D93AD26C8@tntluoma.com> In-Reply-To: <41D9BA53.4060105@locolomo.org> References: <06DDB71C-5DB4-11D9-B56F-000D9333E43C@secure-computing.net> <15416223037.20050103193803@hexren.net> <6074EB8D-5DC6-11D9-89A5-000D93AD26C8@tntluoma.com> <F0BE3E23-5DC8-11D9-B56F-000D9333E43C@secure-computing.net> <41D9BA53.4060105@locolomo.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 3, 2005, at 4:34 PM, Erik Norgaard wrote: > Eric F Crist wrote: > >> elif [ "$grog_firewall_enable" <> "YES" or "NO" ] >> then >> echo "Syntax error in /etc/rc.conf file. grog_firewall_enable >> must be YES or NO" >> fi > > I don't know if you're on 5.x, nor whether you use ipfw, ipfilter or > pf - I wrote a replacement for ipfilter as I got dizzy trying to > maintain a too long ruleset so I wanted to split it into multiple > files. > > On 5.x things get a lot simpler. In /etc/rc.d there are plenty of > scripts to look at - don't look at rc.firewall. [lots of good info snipped] > Finally, don't use bash, use /bin/sh and nothing else, you don't know > if bash is available when your script run. > > Regarding your script, which I got deleted from this mail (sorry), I > think there is an error: > > > if [ "$grog_firewall_enable" = "YES" ] > > this "=" is assignment and will always evaulate to true. You want > > if [ "$grog_firewall_enable" -eq "YES" ] > > I'm not sure if "==" works, but always be careful you're not using > asignment in if-statements. either "-eq" or "=" will work in /bin/sh scripts. Assignment is done like this foo=bar so you have to be careful about quotes and spacing. (Learning PHP was hard because there you DO have to use == and not = Eric - see 'man test' for the proper ways to do greater-than, less-than, greater-or-equal, etc in sh TjL ps - re: this quote: On Jan 3, 2005, at 4:34 PM, Erik Norgaard wrote: > rc.subr also contains a "checkyesno" function answering your question > above - however, it is normal to check "[Yy][Ee][Ss]" and treat > everything else as a no. After all, what are you gonna do if you only > accept "yes" or "no" but some one typed "yeah right"? You must have a > default action. Yeah, I had a Comp. Sci professor who always typed his name in whenever we wrote a program that asked for user input, so if you were expecting a Y|y|n|N and got "cupper" he wanted to know what you planned to do with that.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2DF07A46-5DD2-11D9-89A5-000D93AD26C8>