From owner-freebsd-stable@FreeBSD.ORG Mon Feb 28 23:09:19 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 3E46B1065672 for ; Mon, 28 Feb 2011 23:09:19 +0000 (UTC) (envelope-from ronald-freebsd8@klop.yi.org) Received: from smtp-out1.tiscali.nl (smtp-out1.tiscali.nl [195.241.79.176]) by mx1.freebsd.org (Postfix) with ESMTP id F15B58FC0A for ; Mon, 28 Feb 2011 23:09:18 +0000 (UTC) Received: from [212.123.145.58] (helo=sjakie.klop.ws) by smtp-out1.tiscali.nl with esmtp (Exim) (envelope-from ) id 1PuC2N-0004I2-7L; Mon, 28 Feb 2011 23:57:55 +0100 Received: from 212-123-145-58.ip.telfort.nl (localhost [127.0.0.1]) by sjakie.klop.ws (Postfix) with ESMTP id 1937114E67; Mon, 28 Feb 2011 23:57:45 +0100 (CET) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes To: "Stephen Montgomery-Smith" , jhell References: <4D6BD83B.3040609@missouri.edu> Date: Mon, 28 Feb 2011 23:57:44 +0100 MIME-Version: 1.0 From: "Ronald Klop" Message-ID: In-Reply-To: User-Agent: Opera Mail/11.01 (FreeBSD) Content-Transfer-Encoding: quoted-printable 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 23:09:19 -0000 On Mon, 28 Feb 2011 23:39:10 +0100, jhell wrote: > > On Mon, 28 Feb 2011 12:15, stephen@ wrote: >> I had a little script that would remove broken links. I used to do it= =20 >> like this: >> >> if ! stat -L $link > /dev/null; then rm $link; fi >> >> But recently (some time in February according to the CVS records) stat= =20 >> 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 =20 > long time and have not had to consider adjusting much in the way of =20 > shell scripting to remove dirty links. > > -c =3D=3D change absolute/messy links to relative > -d =3D=3D delete dangling links > -o =3D=3D warn about links across file systems > -r =3D=3D recurse into subdirs > -s =3D=3D shorten lengthy links > -t =3D=3D show what would be done by -c > -v =3D=3D verbose (show all symlinks) > > > Quite interesting though how such a little tweak has caused a massive =20 > expansion of your command line and required utils. > > > Good luck, > Find has some voodoo for handling links also. Ronald.