[Bug 9106] cp -i (prompt before overwrite) does not work
bugzilla at busybox.net
bugzilla at busybox.net
Fri Aug 12 20:16:45 UTC 2016
https://bugs.busybox.net/show_bug.cgi?id=9106
--- Comment #1 from Daniel Sahlberg <daniel.l.sahlberg at gmail.com> ---
The behaviour seems dependent on ENABLE_FEATURE_NON_POSIX_CP (and therefor the
config option CONFIG_FEATURE_NON_POSIX_CP, "Non-POSIX, but safer, copying to
special nodes"). If the config option is NOT set, then the result is as
described by Fredrik Fornwall. (If the config option IS set, then the result is
as expected).
I believe this is because the -i option is only checked in ask_and_unlink(). If
!ENABLE_FEATURE_NON_POSIX_CP, then open is done with O_TRUNC which succeeds and
therefor ask_and_unlink is never called.
I searched for Posix CP and google returned the following reference:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html
As I read it, you'd need to FIRST check if a file exists, then (if -i is
specified) ask the user and only if the response is affirmative you try to open
the file (with O_TRUNC) and if that FAILS, finally try unlink.
Unfortunately I'm not sure I know enough to contribute to a solution. I could
give a try if someone more experienced would care to guide me :-). Otherwise I
hope the above analysis is helpful!
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list