From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119200 invoked by alias); 14 Jul 2016 17:24:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 119147 invoked by uid 89); 14 Jul 2016 17:24:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Jul 2016 17:24:12 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C730AD6844; Thu, 14 Jul 2016 17:24:10 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-70.phx2.redhat.com [10.3.116.70]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6EHOAR0010660; Thu, 14 Jul 2016 13:24:10 -0400 Subject: Re: [PATCH, contrib] download_prerequisites: check for existing symlinks before making new ones To: Eric Gallager References: <6d8cc2be-c68d-81f9-2274-6a12628b8caa@redhat.com> Cc: gcc-patches@gcc.gnu.org From: Jeff Law Message-ID: <218664c9-aeec-c213-eba3-570ba8879516@redhat.com> Date: Thu, 14 Jul 2016 17:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-07/txt/msg00859.txt.bz2 On 07/14/2016 04:57 AM, Eric Gallager wrote: > On 7/13/16, Jeff Law wrote: >> On 06/27/2016 08:10 PM, Eric Gallager wrote: >>> The last time I ran ./contrib/download_prerequisites, I already had >>> previous symlinks set up from a previous run of the script, so `ln` >>> followed the existing symlinks and created the new ones in the >>> directories to which the symlinks pointed. This patch should fix that >>> by removing the old symlinks before creating new ones. (For some >>> reason the `-f` flag to `ln` that was already there wasn't enough for >>> me.) Tested by running the script and ensuring that the new isl >>> symlink pointed to the correct directory, and that there were no bad >>> symlinks in the old isl directory. Could someone commit this trivial >>> patch for me, or something like it? I don't have write access. >> I'd really rather know why the "-f" flag didn't work for you. The whole >> point of -f is to remove the destination file first. >> >> Jeff >> > > Reading my ln manpage, it describes the "-f" flag like this: > > > -f If the target file already exists, then unlink it so that the > link may occur. (The -f option overrides any previous -i > options.) > > Okay, so that seems like it should do what you say, but the manpage > also describes a separate uppercase "-F" option: > > -F If the target file already exists and is a directory, then > remove it so that the link may occur. The -F option should be > used with either -f or -i options. If none is specified, -f is > implied. The -F option is a no-op unless -s option is speci- > fied. > > So it seems to imply that "-f" will only remove the destination file > if it's a regular file, while "-F" is needed if the destination file > is a directory. The page also has this to say about "-F" later: > > The -F option is FreeBSD extention and should not be used in portable > scripts. > > So this could be a BSD vs. GNU thing. I don't have any BSD systems running. I can confirm that while "-f" refers to files in the man page, it will happy delete the old symlink as well. -bash-4.3$ ln -s /bin/ls jj -bash-4.3$ ln -s -f /bin/bash jj -bash-4.3$ ls -l jj lrwxrwxrwx. 1 law law 9 Jul 14 13:22 jj -> /bin/bash -bash-4.3$ which ln /usr/bin/ln -bash-4.3$ rpm -q --whatprovides /usr/bin/ln coreutils-8.24-6.fc23.x86_64 Could you test this on your system? Jeff