From owner-freebsd-current Tue Aug 8 16:59:43 2000 Delivered-To: freebsd-current@freebsd.org Received: from mta02-svc.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by hub.freebsd.org (Postfix) with ESMTP id 98B6A37B89A for ; Tue, 8 Aug 2000 16:59:36 -0700 (PDT) (envelope-from mark@ukug.uk.freebsd.org) Received: from parish.my.domain ([62.253.84.63]) by mta02-svc.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20000809005842.DLR3760.mta02-svc.ntlworld.com@parish.my.domain> for ; Wed, 9 Aug 2000 00:58:42 +0000 Received: (from mark@localhost) by parish.my.domain (8.9.3/8.9.3) id AAA04803 for current@freebsd.org; Wed, 9 Aug 2000 00:59:30 +0100 (BST) (envelope-from mark) Date: Wed, 9 Aug 2000 00:59:29 +0100 From: Mark Ovens To: current@freebsd.org Subject: Request for review/comments - new option for uname(1) Message-ID: <20000809005929.K250@parish> Reply-To: Mark Ovens Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="82I3+IH0IqGh5yIs" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i Organization: Total lack of Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit The output of ``uname -a'' appears in hundreds of e-mails and PRs yet the output format is not ideal for this (especially e-mail in 80-column mail readers) as it is a single line. Attached is a patch for an enhancement I've made that adds a new option ``-A'' (rather than change ``-a'') that splits it up into 3 lines thus making it better for including verbatim in e-mails and PRs: # uname -A FreeBSD parish 4.1-STABLE FreeBSD 4.1-STABLE #0: Tue Aug 8 00:51:02 BST 2000 mark@parish:/usr/src/sys/compile/PARISH i386 The only thing I couldn't work out is why sysctl() adds 5 spaces after the date sub-string, so I've haven't stripped them out (hence the indented third line). Is there any reason why this is unacceptable and could not be committed? BTW, please Cc: me. Thanks for your time. -- 4.4 - The number of the Beastie ________________________________________________________________ 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark mailto:marko@freebsd.org http://www.radan.com --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=us-ascii Content-Description: Diff for uname.c Content-Disposition: attachment; filename="uname.diff" --- uname.c.orig Tue Aug 8 21:32:36 2000 +++ uname.c Tue Aug 8 21:53:20 2000 @@ -61,16 +61,20 @@ #define RFLAG 0x04 #define SFLAG 0x08 #define VFLAG 0x10 +#define AFLAG 0x20 u_int flags; int ch, mib[2]; size_t len, tlen; char *p, *prefix, buf[1024]; flags = 0; - while ((ch = getopt(argc, argv, "amnprsv")) != -1) + while ((ch = getopt(argc, argv, "Aamnprsv")) != -1) switch(ch) { + case 'A': case 'a': flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG); + if (ch == 'A') + flags |= AFLAG; break; case 'p': case 'm': @@ -137,9 +141,22 @@ len = sizeof(buf); if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) err(1, "sysctl"); - for (p = buf, tlen = len; tlen--; ++p) - if (*p == '\n' || *p == '\t') - *p = ' '; + + if (flags & AFLAG) { + for (p = buf, tlen = len; tlen--; ++p) + if (*p == ':') { + *++p = '\n'; + break; + } + + if (buf[strlen(buf) - 1] == '\n') + buf[strlen(buf) - 1] = '\0'; + } else { + for (p = buf, tlen = len; tlen--; ++p) + if (*p == '\n' || *p == '\t') + *p = ' '; + } + (void)printf("%s%.*s", prefix, (int)len, buf); prefix = " "; } --82I3+IH0IqGh5yIs-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message