Skip to content

Commit

Permalink
cp: fix -i and -v messages.
Browse files Browse the repository at this point in the history
cp -i was showing the _source_ rather than the destination, while -v
was only showing the source rather than the source _and_ the destination.
  • Loading branch information
enh-google authored and landley committed Sep 13, 2024
1 parent aea9568 commit 9cde583
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions toys/posix/cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,20 @@ static int cp_node(struct dirtree *try)
if (!faccessat(cfd, catch, F_OK, 0) && !S_ISDIR(cst.st_mode)) {
if (S_ISDIR(try->st.st_mode))
error_msg("dir at '%s'", s = dirtree_path(try, 0));
else if ((flags & FLAG_F) && unlinkat(cfd, catch, 0))
else if (FLAG(F) && unlinkat(cfd, catch, 0))
error_msg("unlink '%s'", catch);
else if (flags & FLAG_i) {
fprintf(stderr, "%s: overwrite '%s'", toys.which->name,
s = dirtree_path(try, 0));
else if (FLAG(i)) {
fprintf(stderr, "%s: overwrite '%s'", toys.which->name, catch);
if (yesno(0)) rc++;
} else if (!((flags&FLAG_u) && nanodiff(&try->st.st_mtim, &cst.st_mtim)>0)
&& !(flags & FLAG_n)) rc++;
} else if (!(FLAG(u) && nanodiff(&try->st.st_mtim, &cst.st_mtim)>0)
&& !FLAG(n)) rc++;
free(s);
if (!rc) return save;
}

if (flags & FLAG_v) {
printf("%s '%s'\n", toys.which->name, s = dirtree_path(try, 0));
if (FLAG(v)) {
printf("%s '%s' -> '%s'\n", toys.which->name, s = dirtree_path(try, 0),
catch);
free(s);
}

Expand Down

0 comments on commit 9cde583

Please sign in to comment.