Subject: bin/19642: Merge machine(1) command into uname(1)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bmeurer@unix-ag.org>
List: netbsd-bugs
Date: 01/02/2003 05:55:24
>Number:         19642
>Category:       bin
>Synopsis:       Merge machine(1) command into uname(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 02 05:56:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Benedikt Meurer
>Release:        1.6
>Organization:
University Siegen
>Environment:
NetBSD endor 1.6 NetBSD 1.6 (ENDOR) #1: Sun Dec 22 12:05:43 CET 2002 bmeurer@endor:/usr/src/sys/arch/i386/compile/ENDOR i386

>Description:
The machine(1) is really a simple wrapper for uname, so it would be
a better solution to merge the machine(1) command into the uname(1)
command.
>How-To-Repeat:

>Fix:
Apply the following patch to uname and remove the machine command.

diff -ruN ../uname.sav/Makefile ./Makefile
--- ../uname.sav/Makefile	Sat Dec 28 17:04:47 2002
+++ ./Makefile	Sat Dec 28 17:05:22 2002
@@ -2,5 +2,7 @@
 #	from: @(#)Makefile	5.3 (Berkeley) 5/11/90
 
 PROG=	uname
+MAN=	machine.1 uname.1
+LINKS=	${BINDIR}/uname ${BINDIR}/machine
 
 .include <bsd.prog.mk>
diff -ruN ../uname.sav/machine.1 ./machine.1
--- ../uname.sav/machine.1	Thu Jan  1 01:00:00 1970
+++ ./machine.1	Sat Dec 28 17:05:50 2002
@@ -0,0 +1,55 @@
+.\"	$NetBSD: machine.1,v 1.4 1997/10/19 04:41:01 lukem Exp $
+.\"
+.\" Copyright (c) 1980, 1990 The Regents of the University of California.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"	This product includes software developed by the University of
+.\"	California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"	from: @(#)machine.1	5.5 (Berkeley) 7/26/91
+.\"	$NetBSD: machine.1,v 1.4 1997/10/19 04:41:01 lukem Exp $
+.\"
+.Dd July 26, 1991
+.Dt MACHINE 1
+.Os
+.Sh NAME
+.Nm machine
+.Nd print machine type
+.Sh SYNOPSIS
+.Nm
+.Sh DESCRIPTION
+The
+.Nm
+command displays the machine type.
+.Sh SEE ALSO
+.Xr make 1
+.Sh HISTORY
+The
+.Nm
+command is
+.Ud .
diff -ruN ../uname.sav/uname.c ./uname.c
--- ../uname.sav/uname.c	Sat Dec 28 16:50:55 2002
+++ ./uname.c	Sat Dec 28 17:08:52 2002
@@ -73,48 +73,54 @@
 
 	(void)setlocale(LC_ALL, "");
 
-	while ((c = getopt(argc,argv,"amnprsv")) != -1) {
-		switch (c) {
-		case 'a':
-			print_mask |= PRINT_ALL;
-			break;
-		case 'm':
-			print_mask |= PRINT_MACHINE;
-			break;
-		case 'n':
-			print_mask |= PRINT_NODENAME;
-			break;
-		case 'p':
-			print_mask |= PRINT_MACHINE_ARCH;
-			break;
-		case 'r': 
-			print_mask |= PRINT_RELEASE;
-			break;
-		case 's': 
-			print_mask |= PRINT_SYSNAME;
-			break;
-		case 'v':
-			print_mask |= PRINT_VERSION;
-			break;
-		default:
+	if (!strcmp(getprogname(), "machine")) {
+		print_mask = PRINT_MACHINE;
+	}
+	else {
+		while ((c = getopt(argc,argv,"amnprsv")) != -1) {
+			switch (c) {
+			case 'a':
+				print_mask |= PRINT_ALL;
+				break;
+			case 'm':
+				print_mask |= PRINT_MACHINE;
+				break;
+			case 'n':
+				print_mask |= PRINT_NODENAME;
+				break;
+			case 'p':
+				print_mask |= PRINT_MACHINE_ARCH;
+				break;
+			case 'r': 
+				print_mask |= PRINT_RELEASE;
+				break;
+			case 's': 
+				print_mask |= PRINT_SYSNAME;
+				break;
+			case 'v':
+				print_mask |= PRINT_VERSION;
+				break;
+			default:
+				usage();
+				/* NOTREACHED */
+			}
+		}
+	
+		if (optind != argc) {
 			usage();
 			/* NOTREACHED */
 		}
-	}
-	
-	if (optind != argc) {
-		usage();
-		/* NOTREACHED */
-	}
 
-	if (!print_mask) {
-		print_mask = PRINT_SYSNAME;
+		if (!print_mask) {
+			print_mask = PRINT_SYSNAME;
+		}
 	}
 
 	if (uname(&u) != 0) {
 		err(EXIT_FAILURE, "uname");
 		/* NOTREACHED */
 	}
+
 	if (print_mask & PRINT_MACHINE_ARCH) {
 		int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
 		size_t len = sizeof (machine_arch);
>Release-Note:
>Audit-Trail:
>Unformatted: