summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-06-29 20:29:35 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-06-29 20:29:35 +0000
commitca25e022f078e36e47224e252b65c68d25ad7897 (patch)
tree4ed3c99315f279e62719d4fbaa5c9f37a6ceef0f
parentce37fd98bb818981d25fa914945966e4ac29013b (diff)
Include OS as part of output; add -k option like SunOS
-rw-r--r--usr.bin/arch/arch.110
-rw-r--r--usr.bin/arch/arch.c45
2 files changed, 52 insertions, 3 deletions
diff --git a/usr.bin/arch/arch.1 b/usr.bin/arch/arch.1
index 7e71d88f56c..6d5e4b62047 100644
--- a/usr.bin/arch/arch.1
+++ b/usr.bin/arch/arch.1
@@ -26,7 +26,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $OpenBSD: arch.1,v 1.1 1996/06/23 04:22:36 tholo Exp $
+.\" $OpenBSD: arch.1,v 1.2 1996/06/29 20:29:34 tholo Exp $
.\"
.Dd June 22, 1996
.Dt ARCH 1
@@ -36,10 +36,18 @@
.Nd print architecture type
.Sh SYNOPSIS
.Nm arch
+.Op Fl k
.Sh DESCRIPTION
The
.Nm arch
command displays the machine's architecture type.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl k
+Display the kernel architecture instead of application
+architecture.
+.El
.Sh SEE ALSO
.Xr machine 1
.Sh HISTORY
diff --git a/usr.bin/arch/arch.c b/usr.bin/arch/arch.c
index a4a9bee8b31..39b028863ca 100644
--- a/usr.bin/arch/arch.c
+++ b/usr.bin/arch/arch.c
@@ -29,16 +29,57 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: arch.c,v 1.1 1996/06/23 04:22:36 tholo Exp $";
+static char rcsid[] = "$OpenBSD: arch.c,v 1.2 1996/06/29 20:29:34 tholo Exp $";
#endif /* not lint */
+#include <stdio.h>
+#include <locale.h>
+#include <unistd.h>
#include <sys/param.h>
+#include <sys/utsname.h>
+#include <err.h>
+
+static void usage __P((void));
int
main(argc, argv)
int argc;
char *argv[];
{
- puts(MACHINE_ARCH);
+ struct utsname uts;
+ char *arch;
+ int c;
+
+ setlocale(LC_ALL, "");
+
+ arch = MACHINE_ARCH;
+ while ((c = getopt(argc, argv, "k")) != -1)
+ switch (c) {
+ case 'k':
+ arch = MACHINE;
+ break;
+ default:
+ usage();
+ /* NOTREASCHED */
+ }
+ if (optind != argc) {
+ usage();
+ /* NOTREACHED */
+ }
+ if (uname(&uts)) {
+ err(1, NULL);
+ /* NOTREACHED */
+ }
+ fputs(uts.sysname, stdout);
+ fputc('.', stdout);
+ fputs(arch, stdout);
+ fputc('\n', stdout);
exit(0);
}
+
+static void
+usage()
+{
+ fprintf(stderr, "usage: arch [-k]\n");
+ exit(1);
+}