Jim Cheetham wrote:
On Wed, Jun 11, 2008 at 1:41 PM, Douglas Royds <[EMAIL PROTECTED]> wrote:
Of course, all this would be generally much better done in a
programming language other than bash :-) but where's the fun in that?
What's sad here is that we actually think this is interesting.

Bah, found another fault ...

$ twhich htdigest
-rwxr-xr-x 1 root root 7.7K Feb  4 19:59 /usr/bin/htdigest
$ twhich htdigest2
lrwxrwxrwx 1 root root 8 Feb  8 06:48 /usr/bin/htdigest2 -> htdigest
ls: htdigest: No such file or directory

Not all symlinks have absolute targets, and therefore we'd have to add
the dirname of the link to the target when doing the next lookup.

#!/bin/bash
candidate=`which $1`
while [ -L "$candidate" ]; do
 ls -lh --color $candidate
 DN=$(dirname $candidate)
 candidate=$(stat -c %N $candidate|cut -d\` -f3|cut -d\' -f1)
 if [ "$(basename $candidate)" == "$candidate" ]
     then candidate="$DN/$candidate"
 fi
done
ls -lh --color $candidate

Good. Well spotted.

I like the style, used by you:

   variable=$(executable args)

Better than my:

   variable=`executable args`








=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================

Reply via email to