From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6690 invoked from network); 20 Apr 2005 09:16:00 -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 09:16:00 -0000 Received: (qmail 34231 invoked from network); 20 Apr 2005 09:15:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Apr 2005 09:15:54 -0000 Received: (qmail 6392 invoked by alias); 20 Apr 2005 09:15:45 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8717 Received: (qmail 6373 invoked from network); 20 Apr 2005 09:15:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 20 Apr 2005 09:15:44 -0000 Received: (qmail 33128 invoked from network); 20 Apr 2005 09:15:44 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 20 Apr 2005 09:15:39 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Wed, 20 Apr 2005 10:13:58 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 20 Apr 2005 10:18:55 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j3K9Fbsu018165 for ; Wed, 20 Apr 2005 10:15:37 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j3K9Fbsi018162 for ; Wed, 20 Apr 2005 10:15:37 +0100 Message-Id: <200504200915.j3K9Fbsi018162@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: "zsh-users@sunsite.dk" Subject: Re: Testing for broken symlinks In-reply-to: References: Date: Wed, 20 Apr 2005 10:15:37 +0100 From: Peter Stephenson X-OriginalArrivalTime: 20 Apr 2005 09:18:55.0094 (UTC) FILETIME=[F9A28160:01C54589] 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, TO_ADDRESS_EQ_REAL autolearn=no version=3.0.2 X-Spam-Hits: -2.6 "Eric Mangold" wrote: > Is there any way to test if a symlink is broken? This will work: broken=(mylinktest(N-@)) if (( ${#broken} )); then print mylinktest is a broken symbolic link else print mylinktest is not a symbolic link or is not broken fi The basic point is that the command line argument mylinktest(N-@) is removed unless mylinktest is a broken symbolic link, so you may have a more efficient way to use the fact. This works because - makes the shell follow symbolic links, while @ tells it to look only for symbolic links. The only files that are still resolved as symbolic links are those that are broken. The N flag then removes any failed glob, i.e. those not broken symbolic links. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************