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

Reply via email to