Date: Mon, 28 Feb 2011 23:57:44 +0100 From: "Ronald Klop" <ronald-freebsd8@klop.yi.org> To: "Stephen Montgomery-Smith" <stephen@missouri.edu>, jhell <jhell@dataix.net> Cc: FreeBSD Stable <freebsd-stable@freebsd.org> Subject: Re: Change in behavior to stat(1) Message-ID: <op.vrmx2izj8527sy@212-123-145-58.ip.telfort.nl> In-Reply-To: <alpine.BSF.2.00.1102281732260.67308@qvfongpu.qngnvk.ybpny> References: <4D6BD83B.3040609@missouri.edu> <alpine.BSF.2.00.1102281732260.67308@qvfongpu.qngnvk.ybpny>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 28 Feb 2011 23:39:10 +0100, jhell <jhell@dataix.net> 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
>> 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,
>
Find has some voodoo for handling links also.
Ronald.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.vrmx2izj8527sy>
