sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit df6599ef784ba71420c2e06b0c9b21fb74654ad7
parent 688384568cba9f3e369434bf220b988da2f8357c
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 30 Jul 2021 11:23:03 -0700

mv: Only remove source if copy succeeded

Diffstat:
Mmv.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mv.c b/mv.c @@ -20,9 +20,14 @@ mv(const char *s1, const char *s2, int depth) if (errno == EXDEV) { cp_aflag = cp_rflag = cp_pflag = 1; cp_follow = 'P'; + cp_status = 0; + rm_status = 0; cp(s1, s2, depth); - recurse(AT_FDCWD, s1, NULL, &r); - return (mv_status = cp_status || rm_status); + if (cp_status == 0) + recurse(AT_FDCWD, s1, NULL, &r); + if (cp_status || rm_status) + mv_status = 1; + return 0; } mv_status = 1;