/usr boot time dependencies

Pekka Savola pekkas at netcore.fi
Wed Aug 20 05:45:33 UTC 2003


On Wed, 20 Aug 2003, Florian La Roche wrote:
> > well, the use of sort and grep in pipelines including awk always bugs 
> > me a bit:
> > 
> > sysctl -a | awk '$0 ~ /^net\.ipv6\.conf\./ { split($1,a,/\./); 
> > foo[a[4]] = a[4]; } END {asort(foo); for (i in foo) { if (foo[i] != 
> > "all" && foo[i] != "default") print foo[i];}}'
> > 
> > at a minimum, grep regex | awk '....' can nearly always trivially be
> > replaced with: awk '$0 ~ /regex/ ....' - grep | awk -> no! :)
> 
> Please submit patches into bugzilla, if you want to have those
> replaced. I also think that some of those constructs should be
> replaced.

At least the first three-line systctl -a parsing is WAY too confusing to a
random John Doe reading the code.  Just because we can do it doesn't mean
we have to.  This is not an obfuscated string parsing contest :-), when we
could just have:

sysctl -a | grep "^net\.ipv6\.conf\." | awk -F. '{ print $4 }' | sort -u | while read interface; 

perhaps the first grep could be eliminated, but it's much more readable if 
we keep it in.

Another fix, in this particular case, might be to augment sysctl to be 
able to print all the sub-branches of a given value, like:

sysctl -a net.ipv6.conf

would print out:

eth0.router_solicitation_delay = 1
eth0.router_solicitation_interval = 4
....

could be usable otherwise too.

-- 
Pekka Savola                 "You each name yourselves king, yet the
Netcore Oy                    kingdom bleeds."
Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings





More information about the devel mailing list