"Simple" but non-portable == useless.
Karl Lehenbauer
karl at ficc.ferranti.com
Fri Feb 1 02:43:59 AEST 1991
In article <1991Jan30.055113.26485 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
>I think he was talking about my script, not Karl's. About two-thirds of
>those 30 lines were debugging, error messages, and added space for
>legibility. Since I've been criticized for verbosity for putting
>in such features, they've been duly excised.
Yes, my Tcl script contained 15 lines of code. There were 21 comments and blank
lines to improve readability and maintainability. ("Though a program be but
three lines long, someday it will have to be maintained." -- Tao of Programming)
Below, I have crushed it into six lines just to show it could be done. Yes,
it still works. You can get it down to one line by grouping the remaining
lines together with semicolons where the lines don't end with open curly
brackets. Compare this to the alt.sources posting of pathdups.tcl and consider
in general the hacked-out shell scripts you've seen and I think most people
will agree that
least_number_of_lines_of_code != most_easily_understood_program
foreach dir [split : [getenv PATH]] { cd $dir
foreach file [globok *] { if [info exists files($file)] {
set files($file) [concat $files($file) $dir]; set dups($file) ""
} else { set files($file) $dir } } }
set index "" ; while {[next_element dups index file]} {
print "$file => $files($file)\n" }
--
-- "If it ain't too broke, don't fix it." -- me, with apologies to Bert Lantz
More information about the Alt.sources.d
mailing list