[patch] rc.d cleanup

Frank Mayhar frank at exit.com
Mon Aug 1 18:59:27 GMT 2005


On Mon, 1 Aug 2005 13:29:00 -0500 (CDT)
diz at linuxpowered.com wrote:
> Well I certainly respect the opinions, but respectfully when has the use
> of && and || become obfuscation? Secondly, the use of shell style blocks
> of code is similar to the way they are done in C where curly-braces are
> used to enclose blocks of code. I honestly don't believe that it is
> because of people who look at C and shell code, it is probably more due to
> the foundation of all that existing shell code we read that does use IF
> statements instead of logical AND/OR.

That may be true for you, but I suspect that you don't write much (if any) C,
do you?  When one is accustomed to seeing standard if/else with proper
indentation, the kind of thing you propose is indeed obfuscatory.  This is one
of the reasons that Perl is nearly unmaintainable, and that is the name of the
game in one word:  Maintainability.

Most of us aren't experts in /bin/{ba}sh syntax, nor will we be.

> What is the point of using a bulky
> IF statement for the evaluating simple true/false situation that the shell
> supports with && or ||?

The point is that it is more clear.  It expresses exactly what it is:  A
conditional statement in a programming language.  The "&&" and "||" syntax
is just a shortcut to do the same thing.  Like most shortcuts, it has its
place, but should be avoided when writing for a general audience.

Ghods know I'm as guilty as anyone of violating this rule, but I try...
-- 
Frank Mayhar frank at exit.com	http://www.exit.com/
Exit Consulting                 http://www.gpsclock.com/
                                http://www.exit.com/blog/frank/


More information about the freebsd-hackers mailing list