From c701c10e3cbd3368729afe61a866d23be3094e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 18 Feb 2022 14:34:40 +0100 Subject: [PATCH] uname: -v: strip final whitespace compatibly with uname(3) X-Mutt-PGP: OS This restores POSIX.1 conformance PR: 260938 --- usr.bin/uname/uname.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c index e97b9c3cb..109505e4b 100644 --- a/usr.bin/uname/uname.c +++ b/usr.bin/uname/uname.c @@ -256,8 +256,12 @@ NATIVE_SYSCTL2_GET(version, CTL_KERN, KERN_VERSION) { p = NATIVE_BUFFER; n = NATIVE_LENGTH; for (; n--; ++p) - if (*p == '\n' || *p == '\t') - *p = ' '; + if (*p == '\n' || *p == '\t') { + if (n > 1) + *p = ' '; + else + *p = '\0'; + } } NATIVE_SET; NATIVE_SYSCTL2_GET(platform, CTL_HW, HW_MACHINE) { -- 2.30.2