This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 'cp' utility bug when <dest-name>.exe file exist.


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@redhat.com    +1-801-349-2682
>Libvirt virtualization library http://libvirt.org

Phil Rising   risingp1@nationwide.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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]