From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13324 invoked from network); 20 Apr 2005 10:53:47 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 20 Apr 2005 10:53:47 -0000 Received: (qmail 86051 invoked from network); 20 Apr 2005 10:53:41 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Apr 2005 10:53:41 -0000 Received: (qmail 21510 invoked by alias); 20 Apr 2005 10:53:32 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8718 Received: (qmail 21490 invoked from network); 20 Apr 2005 10:53:30 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 Apr 2005 10:53:30 -0000 Received: (qmail 84932 invoked from network); 20 Apr 2005 10:53:30 -0000 Received: from master.altlinux.ru (62.118.250.235) by a.mx.sunsite.dk with SMTP; 20 Apr 2005 10:53:26 -0000 Received: from solemn.turbinal.org (localhost.localdomain [127.0.0.1]) by master.altlinux.ru (Postfix) with ESMTP id 7B11BE46CA for ; Wed, 20 Apr 2005 14:53:25 +0400 (MSD) Received: by solemn.turbinal.org (Postfix, from userid 500) id C005EA58EA; Wed, 20 Apr 2005 14:51:55 +0400 (MSD) Date: Wed, 20 Apr 2005 14:51:55 +0400 From: Alexey Tourbin To: zsh-users@sunsite.dk Subject: Re: Testing for broken symlinks Message-ID: <20050420105155.GR21153@solemn.turbinal.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jsrFa/5v3cIbBmG8" Content-Disposition: inline In-Reply-To: X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 --jsrFa/5v3cIbBmG8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --jsrFa/5v3cIbBmG8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFCZjRLfBKgtDjnu0YRAlHiAKCMtDHSqAEhkHU9kQxPF1GI4lObPQCeI59G nPCjBXsftEr7A+TkTNcNzao= =c7jX -----END PGP SIGNATURE----- --jsrFa/5v3cIbBmG8--