From 51aab4cd76991df3e2961dbdc2151631f17afce1 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 4 Mar 2019 08:05:13 -0600 Subject: Don't print (null) in error messages. --- toys/posix/chgrp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toys/posix/chgrp.c b/toys/posix/chgrp.c index 85a4102c..8c2e95b4 100644 --- a/toys/posix/chgrp.c +++ b/toys/posix/chgrp.c @@ -58,10 +58,9 @@ static int do_chgrp(struct dirtree *node) if (ret || (flags & FLAG_v)) { char *path = dirtree_path(node, 0); if (flags & FLAG_v) - xprintf("%s %s%s%s %s\n", toys.which->name, - TT.owner_name ? TT.owner_name : "", - toys.which->name[2]=='o' && TT.group_name ? ":" : "", - TT.group_name ? TT.group_name : "", path); + xprintf("%s %s%s%s %s\n", toys.which->name, TT.owner_name, + (toys.which->name[2]=='o' && *TT.group_name) ? ":" : "", + TT.group_name, path); if (ret == -1 && !(toys.optflags & FLAG_f)) perror_msg("'%s' to '%s:%s'", path, TT.owner_name, TT.group_name); free(path); @@ -77,6 +76,7 @@ void chgrp_main(void) char **s, *own; TT.owner = TT.group = -1; + TT.owner_name = TT.group_name = ""; // Distinguish chown from chgrp if (ischown) { -- cgit v1.2.3