"Simple" but non-portable == useless.

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Fri Feb 1 22:42:09 AEST 1991


In article <LH497M at xds2.ferranti.com> karl at 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



More information about the Alt.sources.d mailing list