aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/cp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-12-18 11:13:35 -0600
committerRob Landley <rob@landley.net>2014-12-18 11:13:35 -0600
commitc2d6740a142f1e6b71b9bc320b09575e29867bc2 (patch)
tree742c026b16a7a3b3b366c6e8b420ab470d150e12 /toys/posix/cp.c
parentbce0e002dc5d25ae109e0b72da071986f211cf9c (diff)
downloadtoybox-c2d6740a142f1e6b71b9bc320b09575e29867bc2.tar.gz
Decouple cp and mv so mv uses its own --help text.
MV still requires CP enabled until the flag generation logic gets updated.
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r--toys/posix/cp.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 9e83cb80..e83dabae 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -4,11 +4,11 @@
*
* Posix says "cp -Rf dir file" shouldn't delete file, but our -f does.
-// This is subtle: MV options must be in same order (right to left) as CP
-// for FLAG_X macros to work out right.
+// This is subtle: MV options shared with CP must be in same order (right to
+// left) as CP for FLAG_X macros to work out right.
USE_CP(NEWTOY(cp, "<2RHLPp"USE_CP_MORE("rdaslvnF")"fi[-HLPd]"USE_CP_MORE("[-ni]"), TOYFLAG_BIN))
-USE_CP_MV(OLDTOY(mv, cp, "<2"USE_CP_MORE("vnF")"fi"USE_CP_MORE("[-ni]"), TOYFLAG_BIN))
+USE_MV(NEWTOY(mv, "<2"USE_CP_MORE("vnF")"fi"USE_CP_MORE("[-ni]"), TOYFLAG_BIN))
USE_INSTALL(NEWTOY(install, "<1cdDpsvm:o:g:", TOYFLAG_USR|TOYFLAG_BIN))
*
@@ -45,7 +45,7 @@ config CP_MORE
-s symlink instead of copy
-v verbose
-config CP_MV
+config MV
bool "mv"
default y
depends on CP
@@ -55,10 +55,10 @@ config CP_MV
-f force copy by deleting destination file
-i interactive, prompt before overwriting existing DEST
-config CP_MV_MORE
+config MV_MORE
bool
default y
- depends on CP_MV && CP_MORE
+ depends on MV && CP_MORE
help
usage: mv [-vn]
@@ -290,7 +290,7 @@ int cp_node(struct dirtree *try)
if (fdout != AT_FDCWD) xclose(fdout);
- if (CFG_CP_MV && toys.which->name[0] == 'm')
+ if (CFG_MV && toys.which->name[0] == 'm')
if (unlinkat(tfd, try->name, S_ISDIR(try->st.st_mode) ? AT_REMOVEDIR :0))
err = "%s";
}
@@ -321,7 +321,7 @@ void cp_main(void)
else TT.destname = destname;
errno = EXDEV;
- if (CFG_CP_MV && toys.which->name[0] == 'm') {
+ if (CFG_MV && toys.which->name[0] == 'm') {
if (!(toys.optflags & FLAG_f)) {
struct stat st;
@@ -351,6 +351,11 @@ void cp_main(void)
}
}
+void mv_main(void)
+{
+ cp_main();
+}
+
#define CLEANUP_cp
#define FOR_install
#include <generated/flags.h>