NON-SOURCE POSTINGS CONSIDERED HARMFUL!

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Fri Jan 25 02:53:53 AEST 1991


In article <1991Jan17.224403.16050 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
> And just so I am not zapped for not practicing what I preach, here's
> a little script that points out executables in your path whose names
> occur more than once, you know, like /bin/mail and /usr/ucb/mail.
  [ 36-line perl script, including 28 lines of real code ]

Here's a little script that points out executables in your path whose
names occur more than once, you know, like /bin/mail and /usr/ucb/mail.
(N.B. This isn't meant as a clone of Tom's script; it doesn't bother
printing where the conflicts are, for example.) Just so Tom doesn't
accuse me of cheating, I spread everything out onto separate lines, so
this is an 11-line script, including 7 lines of real code.

Now what is easier to maintain: a simple 7-line shell script, or a
28-line perl script?

Moral: Use the right tools for the right job. (And don't pretend that
adding a trivial script to an alt.sources.d posting makes it appropriate
for alt.sources.)

#!/bin/sh
# omit L if no symbolic links
# replace sort -u with sort | uniq if sort doesn't support -u

ls -ilFL `echo "$PATH" | tr : '\012'` \
| sed -n 's/\*$//p' \
| rev \
  | sort -u \
  | sed 's/ .*//' \
  | uniq -d \
| rev

---Dan



More information about the Alt.sources.d mailing list