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.


Oleksandr Gavenko schrieb am 08.06.2010 um 16:47 (+0300):
>   $ 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.

Here's a test script for further amusement. Bottom line is that cp and
shell redirection do quite some unexpected and uncalled-for clobbering.
That should probably be fixed.

          \,,,/
          (o o)
------oOOo-(_)-oOOo------
#!/bin/bash --verbose
dirname=/tmp/tt$(date +%s)
mkdir $dirname && cd $dirname || exit $?
touch eins.exe          # create eins.exe
ls -l
echo 1 > eins           # clobbers eins.exe
ls -l
echo 22 > zwei          # create zwei
cp zwei eins            # refuses to create file (the OP's report)
ls -l
mv eins.exe eins        # rename eins.exe to eins
cp zwei eins            # overwrites eins as expected
ls -l
rm eins                 # delete eins
echo 1 > eins.exe       # recreate eins.exe
ls -l
mv zwei eins            # creates eins, does not clobber eins.exe
ls -l
mv eins zwei            # rename it back to zwei
echo 222 > ../zwei.exe  # create file with extension
cp ../zwei.exe .        # clobbers file without exe extension
ls -l
echo 2222 > zwei        # clobbers file with exe extension
ls -l
cp ../zwei.exe zwei     # refuses to create file
ls -l
mv ../zwei.exe zwei     # creates zwei, does not clobber zwei.exe
ls -l
cp ../zwei .            # clobbers file with exe extension
ls -l
-------------------------

As for the general question, Windows and UNIX are very different, and
Cygwin does a fantastic exe-magic job of bringing the two together, a
great treat for those who want to, or have to, use both systems.

Thanks for that!
-- 
Michael Ludwig

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