| Summary: | cp -i (prompt before overwrite) does not work | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Fredrik Fornwall <fredrik> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | busybox-cvs, fredrik, oliver.schmidhauser |
| Priority: | P5 | ||
| Version: | 1.24.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
|
Description
Fredrik Fornwall
2016-07-29 12:13:45 UTC
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! Fixed in git. Thanks! |