Fun with cp -R error when both foo and foo.exe exist
Dan Kegel
dank@kegel.com
Tue Oct 9 16:22:00 GMT 2018
On Tue, Oct 9, 2018 at 5:03 AM Eric Blake <eblake@redhat.com> wrote:
> whether someone patches the cygwin dll or cp, it seems like some rather
> hairy code for what is normally a rare corner case, so it probably won't
> happen unless someone actually contributes a patch.
Right. Here's a completely untested guess patch:
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1363,7 +1363,15 @@ open (const char *unix_path, int flags, ...)
opt |= PC_CTTY;
}
- if (!(fh = build_fh_name (unix_path, opt, stat_suffixes)))
+ suffix_info *suffices = stat_suffixes;
+ if ((opt & (O_WRONLY|O_BINARY)) == (O_WRONLY|O_BINARY))
+ {
+ /* Hack so 'cp foo bar' doesn't abort with
+ 'cp: cannot create regular file bar: File exists'
+ if bar.exe already exists */
+ suffices = NULL;
+ }
+ if (!(fh = build_fh_name (unix_path, opt, suffices)))
__leave; /* errno already set */
if ((flags & O_NOFOLLOW) && fh->issymlink ())
{
Feel free to throw rotten fruit :-)
- Dan
--
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
More information about the Cygwin
mailing list