Mon, 06 Jun 2005
Simple Bash Debugging: set -{x,u,n}
The bash shell gets more
negative press than it deserves from most "real" programmers. Between
the "I can't see what it's doing, I need an echo after nearly every
line!" and the "Why doesn't it have a check option like perl's -c!?"
most people that only occasionally dip in to bash end up frustrated by it's
lack of features. All because they can't be bothered to read the man
page...
I'm going to show you three simple bash "tricks" that'll make your script debugging a lot easier; and none of them require that much searching to find!. Each of the three tidbits presented can be used in one of two ways, they can either be placed one to a line near the top of your shell scripts, just under the shebang line like this, 'set -x', or they can be used as command line arguments to bash itself (bash -x script.sh).
First up we have the '-x' option. This provides a simple trace of each and every command executed by the shell script, it also shows the interpolated values of the variables; which can save a lot of echo's and printf's!
Next up we have '-n', the syntax checker. When this is specified the script doesn't actually run but instead has it's syntax checked for any errors. This removes the annoying "String not terminated" messages that you'll occasionally get from not terminating your strings. Only when '-n' is specified you don't run half a script, leaving the system in an inconsistent state.
The last of our time-savers is the '-u' option, this forces any undefined variables to terminate the script rather than carry on with no values. Although this is often useful, and saves you backtracking through the output of '-x' to find the undeclared value, you can't combine it with the '-n' option. You have to allow the script to run in order for the undefined values to be detected; while this is less than ideal it's better than nothing...
I hope these three lesser known bash features make your scripting more enjoyable and productive, I've lost count of the time they've saved me!
Like this post? - Digg Me! | Add to del.icio.us! | reddit this!
Posted: 2005/06/06 22:55 | /tools/commandline | Permanent link to this entry | This entry + same date
The 22 Immutable Laws of Branding -- Book Review
After the enjoyable and easy to read "22 Immutable Laws of Marketing" (my
review) I decided to give "The 22 Immutable Laws of Branding" an
afternoon of my time. This book is very similar in presentation, format
and even writing style to the "Laws of Marketing". It's an accessible,
easy read in which each law is broken down in to a very short chapter
that makes it as enjoyable to dip in to while on the go as it does to
read cover to cover.
As you'd expect from the title, this book focuses on branding. Using brands that were current at the time, it presents the authors thoughts on how a brand should be maintained, why tightening your focus is always better than line extension and why a number of the less successful brands suffer their fates. Using a number of (mostly) anecdotal examples the essential points of what not to do with your brand are conveyed in an easy to following and occasionally light-hearted tone.
Although the "The 22 Immutable Laws of Branding" contains nothing as profound as the "Laws of Marketing" it does provide some valuable insights on how the big players of the time, some smart and some not so, approached their brands and tried to exploit them. Summary: 6/10.
I've also filed this under 22 Immutable Laws of Branding book review.
Like this post? - Digg Me! | Add to del.icio.us! | reddit this!
Posted: 2005/06/06 22:19 | /books | Permanent link to this entry | This entry + same date

