Mercurial > hg > toybox
comparison toys/posix/cp.c @ 1746:b11f536bac74 draft
install -D bugfix from David Halls.
(I tweaked some comment text while I was there.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 21 Mar 2015 15:49:38 -0500 |
parents | 5a00bc5e1c0f |
children |
comparison
equal
deleted
inserted
replaced
1745:1b97da3c7b91 | 1746:b11f536bac74 |
---|---|
2 * | 2 * |
3 * See http://opengroup.org/onlinepubs/9699919799/utilities/cp.html | 3 * See http://opengroup.org/onlinepubs/9699919799/utilities/cp.html |
4 * | 4 * |
5 * Posix says "cp -Rf dir file" shouldn't delete file, but our -f does. | 5 * Posix says "cp -Rf dir file" shouldn't delete file, but our -f does. |
6 | 6 |
7 // This is subtle: MV options shared with CP must be in same order (right to | 7 // options shared between mv/cp must be in same order (right to left) |
8 // left) as CP for FLAG_X macros to work out right. | 8 // for FLAG macros to work out right in shared infrastructure. |
9 | 9 |
10 USE_CP(NEWTOY(cp, "<2RHLPp"USE_CP_MORE("rdaslvnF(remove-destination)")"fi[-HLP"USE_CP_MORE("d")"]"USE_CP_MORE("[-ni]"), TOYFLAG_BIN)) | 10 USE_CP(NEWTOY(cp, "<2RHLPp"USE_CP_MORE("rdaslvnF(remove-destination)")"fi[-HLP"USE_CP_MORE("d")"]"USE_CP_MORE("[-ni]"), TOYFLAG_BIN)) |
11 USE_MV(NEWTOY(mv, "<2"USE_CP_MORE("vnF")"fi"USE_CP_MORE("[-ni]"), TOYFLAG_BIN)) | 11 USE_MV(NEWTOY(mv, "<2"USE_CP_MORE("vnF")"fi"USE_CP_MORE("[-ni]"), TOYFLAG_BIN)) |
12 USE_INSTALL(NEWTOY(install, "<1cdDpsvm:o:g:", TOYFLAG_USR|TOYFLAG_BIN)) | 12 USE_INSTALL(NEWTOY(install, "<1cdDpsvm:o:g:", TOYFLAG_USR|TOYFLAG_BIN)) |
13 * | |
14 | 13 |
15 config CP | 14 config CP |
16 bool "cp" | 15 bool "cp" |
17 default y | 16 default y |
18 help | 17 help |
389 | 388 |
390 return; | 389 return; |
391 } | 390 } |
392 | 391 |
393 if (toys.optflags & FLAG_D) { | 392 if (toys.optflags & FLAG_D) { |
393 TT.destname = toys.optargs[toys.optc-1]; | |
394 if (mkpathat(AT_FDCWD, TT.destname, 0, 2)) | 394 if (mkpathat(AT_FDCWD, TT.destname, 0, 2)) |
395 perror_exit("-D '%s'", TT.destname); | 395 perror_exit("-D '%s'", TT.destname); |
396 if (toys.optc == 1) return; | 396 if (toys.optc == 1) return; |
397 } | 397 } |
398 if (toys.optc < 2) error_exit("needs 2 args"); | 398 if (toys.optc < 2) error_exit("needs 2 args"); |