Version 0 of boilerplate

Updated 2001-09-26 12:22:06

Here's a Wiki location for those code snippets and idioms that might well belong in every script you write.

LV hopes that people explain why for the novices that stumble across the page...


Richard Suchenwirth RS says you should ALWAYS do this:

 proc foo { args } {
      if { [ llength $args ] == 1 } {
          set args [ lindex $args 0 ]
      }
      ...
 }

Phil Ehrens says nearly every executable script should start with this:

 if { [ regexp {(root|wheel)} $::env(GROUP) ] } {
    puts stderr "DID YOU REALLY MEAN TO RUN $::argv0 AS ROOT?"
    exit 666
 }

LV notes for the novice that it is seldom a good idea to accidentally run miscellaneous commands while in the root or wheel group on Unix, as those groups often have write permission on files that should not be changed accidentally.