Skip to content

Commit

Permalink
uname: -v: strip final whitespace compatibly with uname(3)
Browse files Browse the repository at this point in the history
This restores POSIX.1 conformance

PR: 260938
(cherry picked from commit 7e05fa3)
  • Loading branch information
nabijaczleweli authored and mjguzik committed Mar 5, 2022
1 parent d6132e2 commit ed87197
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions usr.bin/uname/uname.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ed87197

Please sign in to comment.