Path: utzoo!utgpu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uwm.edu!psuvax1!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: alt.sources.d Subject: Re: "Simple" but non-portable == useless. Message-ID: <27180:Feb111:42:0991@kramden.acf.nyu.edu> Date: 1 Feb 91 11:42:09 GMT References: <27A5C105.1019@tct.uucp> <1991Jan30.055113.26485@convex.com> Organization: IR Lines: 20 In article karl@ficc.ferranti.com (Karl Lehenbauer) writes: > 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" } Ye gods. You don't handle links, you don't extract the executables, and this is all to avoid #!/bin/csh -f ls -ilLF $path | sed -n 's/\*$//p' | sort -u | sed 's/.* //' | sort | uniq -d Yes, it is a portability problem that you have to remove the L on machines without symbolic links. Yes, the script has a few limitations. But it does the job, it is within 15% of optimal efficiency on this machine, and it is far easier to write, maintain, and understand. ---Dan