Path: utzoo!utgpu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uwm.edu!lll-winken!sun-barr!newstop!texsun!moxie!sugar!ficc!karl From: karl@ficc.ferranti.com (Karl Lehenbauer) Newsgroups: alt.sources.d Subject: Re: "Simple" but non-portable == useless. Message-ID: Date: 31 Jan 91 15:43:59 GMT References: <7628@sugar.hackercorp.com> <11306:Jan2817:58:5291@kramden.acf.nyu.edu> <27A5C105.1019@tct.uucp> <1991Jan30.055113.26485@convex.com> Reply-To: karl@ficc.ferranti.com (Karl Lehenbauer) Organization: Ferranti International Controls Corporation Lines: 26 In article <1991Jan30.055113.26485@convex.com> tchrist@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