Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Testing for broken symlinks
- X-seq: zsh-users 8718
- From: Alexey Tourbin <at@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Testing for broken symlinks
- Date: Wed, 20 Apr 2005 14:51:55 +0400
- In-reply-to: <opspishpc86k1y1x@aspen>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <opspishpc86k1y1x@aspen>
On Wed, Apr 20, 2005 at 05:30:51PM +1000, Eric Mangold wrote:
> Is there any way to test if a symlink is broken?
if [ -L "$f" -a ! -e "$f" ]; then
print "$f: broken symlink"
fi
$ ln -sf /asdf/zxcv .
$ test -L zxcv; echo $?
0
$ test -e zxcv; echo $?
1
$
The point is that lstat(2) succeeds but stat(2) fails on broken
symlinks.
Attachment:
pgpIdqypo0Dec.pgp
Description: PGP signature
Messages sorted by:
Reverse Date,
Date,
Thread,
Author