From owner-freebsd-stable@FreeBSD.ORG Mon Feb 28 22:39:27 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4AD9B106564A for ; Mon, 28 Feb 2011 22:39:27 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id F2E218FC0C for ; Mon, 28 Feb 2011 22:39:26 +0000 (UTC) Received: by vws16 with SMTP id 16so4187878vws.13 for ; Mon, 28 Feb 2011 14:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:date:from:to:cc:subject:in-reply-to :message-id:references:user-agent:x-openpgp-key-id :x-openpgp-key-fingerprint:mime-version:content-type; bh=N8SwOsBIZ0KE7VI1yacJwkApvzNIgnK0N1Q4zSZ8UUk=; b=hp/N/MJyIXmFXx5ifVgBPUtYukK4SAakYQODY5ZOeN3wzbiGpGIcl6TYhYjfow5jgL Z8a4Gkb8FRKMl50Z2q1gNseB5tcUAj5Fn2hnzam0GcuXxW3QZmfhsJloyt/kS3DovTUL nY//SvmgSDAEj2SQMgVurjnVppR9EWcV8vGrg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:x-openpgp-key-id:x-openpgp-key-fingerprint:mime-version :content-type; b=Y1BDuh2hrKmfG4ghMLSdI4pcpGKrnzwywKOxSh04qqSbKBkpC3boDjdzW3rl6NkPGB aP0bRznNw86NpuK2r2SjfRGQBQka/r4nMvRd0zT3b2cQZR5qNIAdyYB4Xb+6/JD3Myrj zpp1kZ9uZk+ZnGgu9U5SRaBnND8rxq9MIwBdM= Received: by 10.52.68.44 with SMTP id s12mr4991669vdt.74.1298932766258; Mon, 28 Feb 2011 14:39:26 -0800 (PST) Received: from disbatch.dataix.local ([99.181.159.74]) by mx.google.com with ESMTPS id w26sm1877382vcf.21.2011.02.28.14.39.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Feb 2011 14:39:25 -0800 (PST) Sender: "J. Hellenthal" Date: Mon, 28 Feb 2011 17:39:10 -0500 From: jhell To: Stephen Montgomery-Smith In-Reply-To: <4D6BD83B.3040609@missouri.edu> Message-ID: References: <4D6BD83B.3040609@missouri.edu> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-OpenPGP-Key-Id: 0x89D8547E X-OpenPGP-Key-Fingerprint: 85EF E26B 07BB 3777 76BE B12A 9057 8789 89D8 547E MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Stable Subject: Re: Change in behavior to stat(1) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Feb 2011 22:39:27 -0000 On Mon, 28 Feb 2011 12:15, stephen@ wrote: > I had a little script that would remove broken links. I used to do it like > this: > > if ! stat -L $link > /dev/null; then rm $link; fi > > But recently (some time in February according to the CVS records) stat was > changed so that stat -L would use lstat(2) if the link is broken. > > So I had to change it to > > if stat -L $link | awk '{print $3}' | grep l > /dev/null; > then rm $link; fi > > but it is a lot less elegant. > > What is the proper accepted way to remove broken links? > > Stephen > You might find sysutils/symlinks interesting. I have been using it a long time and have not had to consider adjusting much in the way of shell scripting to remove dirty links. -c == change absolute/messy links to relative -d == delete dangling links -o == warn about links across file systems -r == recurse into subdirs -s == shorten lengthy links -t == show what would be done by -c -v == verbose (show all symlinks) Quite interesting though how such a little tweak has caused a massive expansion of your command line and required utils. Good luck, -- jhell