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 Tue, Jun 8, 2010 at 08:01, Eric Blake <> wrote:
>
> On 06/08/2010 07:47 AM, Oleksandr Gavenko wrote:
> > ? $ touch my.exe
> > ? $ touch some-file
> > ? $ cp some-file my
> > cp: cannot create regular file `my': File exists
> > ? $ cp -f some-file my
> > cp: cannot create regular file `my': File exists
> >
> > Same happen ever in cmd.exe so this is not 'bash' fault.
>
> This is an issue with the fact that cygwin has to support .exe magic.
> The problem is that cygwin (rightly) refuses to create "my" if "my.exe"
> exists. ?But which is better? ?Cygwin doesn't know whether you meant to
> delete my.exe and replace it with "my", or if you meant to replace
> "my.exe" but keep the magic suffix. ?Since we don't know the right
> hueristics for patching rename(2) (and/or cp(1)) to guess what most
> people want most of the time, I think that the error message is the best
> we can do in this particular case of file name conflict.
>
> But I'm welcome to the idea of changing coreutils to try and do a more
> sensible action, if we can get list consensus on what a more sensible
> action would be.
>
> --
> Eric Blake ?  ? ?+1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>

This seems to be totally cock-eyed. I couldn't reproduce the OP's
results, but then I realized I was using "mv" instead of "cp". "cp"
should behave in the same way as "mv" and do what I say. I had never
encountered this issue and was surprised at some of the things I saw
happen when I tried some commands, such as "echo foobar >foo" when I
had a "foo.exe" in the directory. In this case I would expect "foo" to
be created, but instead the output was written to "foo.exe". In order
to be POSIX-like shouldn't all the tools do exactly what they are told
and forget this exe magic? Clearly there is nothing in the underlying
file system to prevent us from having both foo and foo.exe in the same
directory as can be demonstrated by a simple "touch foo foo.exe"
command. Both files will be created. Both can even have execute
permission set via "chmod +x foo*". Admittedly this has the potential
to confuse the user due to the aforementioned exe magic, but since the
order of evaluation should be clearly defined I don't see that as a
real problem. Keeping with the "Do what I say." approach I would
expect entering "foo" to execute "foo", unless "foo" didn't exist at
which the magic gets applied and "foo.exe", "foo.bat", ... are checked
for in whatever the defined order is. If "foo.exe" is entered then
only "foo.exe" should be looked for and executed if it exists. Why
isn't this the way cygwin operates? There certainly appear to be
inconsistencies within the tools.

Steven Collins

--
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]