delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/06/08/11:43:03

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
Subject: Re: 'cp' utility bug when <dest-name>.exe file exist.
X-KeepSent: F145E76E:EB43EC60-8525773C:005639A6; type=4; name=$KeepSent
Message-ID: <OFF145E76E.EB43EC60-ON8525773C.005639A6-8525773C.005650D6@lnotes-gw.ent.nwie.net>
From: RISINGP1 AT nationwide DOT com
Date: Tue, 8 Jun 2010 11:42:48 -0400
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 06/08/2010 10:52 AM, Eric Blake wrote:
>On 06/08/2010 08:43 AM, Steven Collins wrote:
>> directory as can be demonstrated by a simple "touch foo foo.exe"
>> command. Both files will be created.
>
>Arguably, both should NOT be created, for the same reasons.  That is, it
>is probably worth a patch to make open("foo.exe",O_CREAT|O_EXCL,mode)
>fail if "foo" exists, and open("foo.exe",O_CREAT,mode) delete "foo" if
>it exists, effectively renaming "foo" to "foo.exe".
>

I disagree.  This seems to me to be adopting the Microsoft policy of doing
the user's thinking for them:  "I don't care what they want - we know
what's best for them."  If a person wants to have "foo" and "foo.exe" in
the same directory, that should be allowed.  A few times getting tripped
up by the wrong thing executing will be a good life lesson for the person,
and teach about how different operating systems work to boot.  Should I
create "foo" as an executable, and "foo.exe" exists, then if I want to run
"foo.exe", I should have to call it out specifically.  I can see this
might cause some confusion should, unbeknownst to the user, "foo.exe"
exists earlier in the path than "foo", but that would become an
education on how to use the PATH variable.  This confusion arises
from Cygwin's kowtowing to Microsoft's dubious idea of using extensions to
control the handling of files.

As to the automatic deletion/renaming of a file - DON'T EVER DO THIS!

As to the "cp" issue, while IMHO, it should go ahead and do the copy,
a more instructive error message would be helpful:

cp: cannot create regular file `my': File 'my.exe' exists

>> which the magic gets applied and "foo.exe", "foo.bat",
>
>You are misunderstanding the magic.  It only happens for .exe, and that
>is because the Unix world is steeped in the tradition of suffix-less
>executables, but Windows insists on having the .exe suffix for cmd to be
>able to run an executable.  Cygwin goes to various lengths to try to
>support both, at the expense that you shouldn't have both exist in the
>same directory.  .bat has nothing to do with .exe magic.
>
>> There certainly appear to be
>> inconsistencies within the tools.
>
>Yes, and as they get pointed out, we try to make them more consistent.
>
>-- 
>Eric Blake   eblake AT redhat DOT com    +1-801-349-2682
>Libvirt virtualization library http://libvirt.org

Phil Rising   risingp1 AT nationwide DOT com

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019