mirror of git://git.suckless.org/sbase
mv: Only remove source if copy succeeded
This commit is contained in:
parent
688384568c
commit
df6599ef78
9
mv.c
9
mv.c
|
@ -20,9 +20,14 @@ mv(const char *s1, const char *s2, int depth)
|
||||||
if (errno == EXDEV) {
|
if (errno == EXDEV) {
|
||||||
cp_aflag = cp_rflag = cp_pflag = 1;
|
cp_aflag = cp_rflag = cp_pflag = 1;
|
||||||
cp_follow = 'P';
|
cp_follow = 'P';
|
||||||
|
cp_status = 0;
|
||||||
|
rm_status = 0;
|
||||||
cp(s1, s2, depth);
|
cp(s1, s2, depth);
|
||||||
recurse(AT_FDCWD, s1, NULL, &r);
|
if (cp_status == 0)
|
||||||
return (mv_status = cp_status || rm_status);
|
recurse(AT_FDCWD, s1, NULL, &r);
|
||||||
|
if (cp_status || rm_status)
|
||||||
|
mv_status = 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
mv_status = 1;
|
mv_status = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue