27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

See also Appendix C.<br />

• Break complex scripts into simpler modules. Use functions where appropriate. See Example 35−4.<br />

• Don't use a complex construct where a simpler one will do.<br />

COMMAND<br />

if [ $? −eq 0 ]<br />

...<br />

# Redundant and non−intuitive.<br />

if COMMAND<br />

...<br />

# More concise (if perhaps not quite as legible).<br />

... reading the UNIX source code to the Bourne<br />

shell (/bin/sh). I was shocked at how much simple<br />

algorithms could be made cryptic, and therefore<br />

useless, by a poor choice of code style. I asked<br />

myself, "Could someone be proud of this code?"<br />

Landon Noll<br />

Chapter 33. Scripting With Style 335

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!