Bug 5826 - cross-platform script compatibility
Summary: cross-platform script compatibility
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 3.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Steve Price
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1998-02-23 20:00 UTC by Tony Kimball
Modified: 1998-02-24 16:58 UTC (History)
0 users

See Also:


Attachments
file.diff (450 bytes, patch)
1998-02-23 20:00 UTC, Tony Kimball
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Kimball 1998-02-23 20:00:00 UTC
I find many SVR4 scripts using the -p option of uname to get
BSD uname -m functionality.  Here's a one-line to provide 
script-compatibility.

Fix: ; cd usr.bin/uname; cvs diff -c3 uname.c
Comment 1 sprice 1998-02-23 22:21:44 UTC
> I find many SVR4 scripts using the -p option of uname to get
> BSD uname -m functionality.  Here's a one-line to provide
> script-compatibility.

Actually I think the intent of the -p option is to show
the processor type of the machine, at least according to
a Digital box running OSF1.  Maybe the attached patch 
would be more appropriate?

Steve

Index: uname.1
===================================================================
RCS file: /u/FreeBSD/cvs/src/usr.bin/uname/uname.1,v
retrieving revision 1.5
diff -u -r1.5 uname.1
--- uname.1	1997/08/20 11:03:54	1.5
+++ uname.1	1998/02/23 22:17:58
@@ -39,7 +39,7 @@
 .Nd display information about the system
 .Sh SYNOPSIS
 .Nm
-.Op Fl amnrsv
+.Op Fl amnprsv
 .Sh DESCRIPTION
 The
 .Nm
@@ -54,6 +54,7 @@
 Behave as though the options
 .Fl m ,
 .Fl n ,
+.Fl p ,
 .Fl r ,
 .Fl s ,
 and
@@ -63,6 +64,8 @@
 Write the type of the current hardware platform to standard output.
 .It Fl n
 Write the name of the system to standard output.
+.It Fl p
+Write the processor type to standard output.
 .It Fl r
 Write the current release level of the operating system
 to standard output.
Index: uname.c
===================================================================
RCS file: /u/FreeBSD/cvs/src/usr.bin/uname/uname.c,v
retrieving revision 1.2
diff -u -r1.2 uname.c
--- uname.c	1997/03/29 04:33:22	1.2
+++ uname.c	1998/02/23 22:19:01
@@ -61,13 +61,14 @@
 #define	RFLAG	0x04
 #define	SFLAG	0x08
 #define	VFLAG	0x10
+#define	PFLAG   0x20
 	u_int flags;
 	int ch, mib[2];
 	size_t len, tlen;
 	char *p, *prefix, buf[1024];
 
 	flags = 0;
-	while ((ch = getopt(argc, argv, "amnrsv")) != -1)
+	while ((ch = getopt(argc, argv, "amnprsv")) != -1)
 		switch(ch) {
 		case 'a':
 			flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
@@ -78,6 +79,9 @@
 		case 'n':
 			flags |= NFLAG;
 			break;
+		case 'p':
+			flags |= PFLAG;
+			break;
 		case 'r':
 			flags |= RFLAG;
 			break;
@@ -145,6 +149,15 @@
 	if (flags & MFLAG) {
 		mib[0] = CTL_HW;
 		mib[1] = HW_MACHINE;
+		len = sizeof(buf);
+		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
+			err(1, "sysctl");
+		(void)printf("%s%.*s", prefix, len, buf);
+		prefix = " ";
+	}
+	if (flags & PFLAG) {
+		mib[0] = CTL_HW;
+		mib[1] = HW_MODEL;
 		len = sizeof(buf);
 		if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1)
 			err(1, "sysctl");
Comment 2 Steve Price freebsd_committer freebsd_triage 1998-02-24 16:58:05 UTC
State Changed
From-To: open->closed

New -p option added as requested.  Thanks! 


Comment 3 Steve Price freebsd_committer freebsd_triage 1998-02-24 16:58:05 UTC
Responsible Changed
From-To: freebsd-bugs->steve