diff options
author | Rob Landley <rob@landley.net> | 2013-01-10 20:19:23 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-01-10 20:19:23 -0600 |
commit | 8d84a9928089bef0b489b44e0738c05d6d547dd4 (patch) | |
tree | a009a267249e555cc264d88a926cb4b9275973f5 | |
parent | c428b543f8b7ca55fcd58c8fd090fc06ffebe7ce (diff) | |
download | toybox-8d84a9928089bef0b489b44e0738c05d6d547dd4.tar.gz |
Teach cp to do -n.
-rw-r--r-- | toys/posix/cp.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 9f22a6f0..01ba385c 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -4,7 +4,7 @@ * * TODO: sHLP -USE_CP(NEWTOY(cp, "<2"USE_CP_MORE("rdavsl")"RHLPfip", TOYFLAG_BIN)) +USE_CP(NEWTOY(cp, "<2"USE_CP_MORE("rdavsln")"RHLPfip[-ni]", TOYFLAG_BIN)) config CP bool "cp" @@ -30,10 +30,11 @@ config CP_MORE help usage: cp [-rdavsl] - -r synonym for -R - -d don't dereference symlinks -a same as -dpr + -d don't dereference symlinks -l hard link instead of copy + -n no clobber (don't overwrite DEST) + -r synonym for -R -s symlink instead of copy -v verbose */ @@ -84,10 +85,10 @@ int cp_node(struct dirtree *try) return 0; } - // Handle -i and -v + // Handle -inv - if ((flags & FLAG_i) && !faccessat(cfd, catch, R_OK, 0) - && !yesno("cp: overwrite", 1)) return 0; + if ((flags & (FLAG_i|FLAG_n)) && !faccessat(cfd, catch, R_OK, 0)) + if ((flags & FLAG_n) || !yesno("cp: overwrite", 1)) return 0; if (flags & FLAG_v) { char *s = dirtree_path(try, 0); |