vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Wed, Feb 07, 2007 at 12:11:06AM +0100, Han Boetes wrote: > Antoine Jacoutot wrote: > > +if [ -s /etc/arp.conf ]; then > > + echo 'setting static ARP entries'; arp -Ff /etc/arp.conf > > > /dev/null 2>&1 > > +fi > > I'd like to suggest a construction like this: > > set -- $(stripcom /etc/arp.conf) > if [ $# -gt 0 ]; then > echo 'setting static ARP entries' > arp -Ff /etc/arp.conf >/dev/null 2>&1 > fi > > If the file only contains comments and blank lines nothing is > done. it's true that nothing is done if there's no output from stripcom(), but you're twiddling $@/$*/$# for no good reason if the file contains relevant file entries. currently /etc/rc only fricks with those ("set -- blah") in situations where it shifts them back out. this construction doesn't make any actual *use* of the 'set --' construct other than using it as a way to check if anything actually happened as a result of doing it, which gives it (imo) a two prong detrement of being a bit confusing (ie: why use that technique if you're not really going to take advantage of its unique effects) and also leaving a dirty environment for the rest of the script. using "[ -s /etc/arp.conf ]" is most similar to how /etc/ethers is tested for (with the exception that it doesn't look for rarpd for arp.conf) and also is how (test -s) the rest of the config files are tested. given that that -F is relevant for -s, but still entirely optional, there is some logic in a construct like: if [ X"${arp_flags}" != X"NO" -a -s /etc/arp.conf ]; then echo 'setting static ARP entries'; arp $arp_flags -f /etc/arp.conf fi i'll defer to commiter@ re: redirecting output to /dev/null as i don't know if the rule-of-thumb for do/don't do it. -- jared |
| Thread Tools | |
| Display Modes | |
|
|