From 6bc4a2376c694f813d2ee78af3d749aa2684f391 Mon Sep 17 00:00:00 2001 From: Allan Jude Date: Tue, 31 Oct 2017 21:41:46 -0400 Subject: [PATCH] OpenZFS 8972 - zfs holds: In scripted mode, do not pad columns with spaces Authored by: Allan Jude Approved by: Dan McDonald Reviewed by: Matthew Ahrens Reviewed by: George Melikov Ported-by: Brian Behlendorf OpenZFS-issue: https://www.illumos.org/issues/8972 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3aace5c077 Closes #7063 --- cmd/zfs/zfs_main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 26096e115..924a4d4aa 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -5749,8 +5749,6 @@ print_holds(boolean_t scripted, int nwidth, int tagwidth, nvlist_t *nvl) uint64_t val = 0; time_t time; struct tm t; - char sep = scripted ? '\t' : ' '; - int sepnum = scripted ? 1 : 2; (void) nvpair_value_uint64(nvp2, &val); time = (time_t)val; @@ -5758,8 +5756,13 @@ print_holds(boolean_t scripted, int nwidth, int tagwidth, nvlist_t *nvl) (void) strftime(tsbuf, DATETIME_BUF_LEN, gettext(STRFTIME_FMT_STR), &t); - (void) printf("%-*s%*c%-*s%*c%s\n", nwidth, zname, - sepnum, sep, tagwidth, tagname, sepnum, sep, tsbuf); + if (scripted) { + (void) printf("%s\t%s\t%s\n", zname, + tagname, tsbuf); + } else { + (void) printf("%-*s %-*s %s\n", nwidth, + zname, tagwidth, tagname, tsbuf); + } } } }