From 9cde5834249786ba5239774c787b5db3de1b6d97 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 10 Sep 2024 18:12:58 -0400 Subject: [PATCH] cp: fix -i and -v messages. cp -i was showing the _source_ rather than the destination, while -v was only showing the source rather than the source _and_ the destination. --- toys/posix/cp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 3306c49f..449b5723 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -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); } -- 2.39.2