Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Sat, 9 Jul 2005 12:32:43 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: Unwanted .exe appended to symlinks Message-ID: <20050709163242.GA11356@trixie.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com References: <1120880636 DOT 6400 DOT 7 DOT camel AT localhost DOT localdomain> <42CF4C9D DOT 8000708 AT byu DOT net> <20050709050214 DOT GA10083 AT trixie DOT casa DOT cgf DOT cx> <42CFBE28 DOT 3060808 AT byu DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42CFBE28.3060808@byu.net> User-Agent: Mutt/1.5.8i On Sat, Jul 09, 2005 at 06:08:08AM -0600, Eric Blake wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >According to Christopher Faylor on 7/8/2005 11:02 PM: >> I don't get it. Certainly /cygdrive/c.exe doesn't exist so why would you >> try to link to it? > >The algorithm I used was this: > >1 - If source exists [determined by the return value of readlink >("source"), although just now I realized that for symbolic links, it >should really be the return value of readlink (concat (dirname ("dest"), >"source")) since symbolic links are relative to the destination, not the pwd] > 2a - if source is non-symlink and exists with a trailing . [determined by >access ("source.")] use "source", else use "source.exe", because one of >those two spellings must have made test 1 succeed > 2b - if source is symlink and exists with a trailing .lnk [determined by >readlink ("source.lnk")] use "source", else use "source.exe", because one >of those two spellings must have made test 1 succeed > >I think the cleanup needs to be along these lines - in steps 2a and 2b, do >a sanity check of also checking whether "source.exe" exists. I don't know why you'd ever just assume that .exe exists. Wouldn't it be safer to just do: struct stat st1, st2; stat ("foo", &st1); if (stat ("foo.exe", &st2) == 0 && st2.st_ino == st1.st_ino) return "foo.exe"; else return "foo"; You could add st_dev checking, too, if you were really paranoid. cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/