#!/bin/sh
#
# uname
#
# Author: Jim Vlcek, ByteWare Consulting (uunet!molly!vlcek) 3 Dec 1993
# Tweaked-By: Larry Blische (lkba!lkb@uunet.uu.net)
# Warped-By: Tom Hageman (tom@basil.icce.rug.nl) 8 Dec 1993
# Rewacked-By: Jim Vlcek (uunet!molly!vlcek) 10 Dec 1993
# With-Suggestions-From: Greg Ubben, Nick Holloway
#
# An attempt to implement a SysV-ish "uname" under NeXTStep 3.0
#
# Options
#
# -s	Print the operating system name
# -n	Print the node name (essentially, the hostname)
# -v	Print the operating system version
# -r	Print the operating system release
# -p	Print the host machine's processor type
# -m	Print the machine hardware name
# -a	Print all the above information
#
# Non-SysV options
#
# -i	Print the host identification number (hostid)
#

system=""
node=""
version=""
release=""
processor=""
mach=""
hostid=""
usage="$0: Usage: $0 [-asnvrpm]"

for arg in $*""
do
	case $arg in
	"")	opts=-s ;;
	-[b-z])	opts=$opts" $arg" ;;
	-*)	opts=$opts" "`echo ' ' $arg | sed 's/-*\([^- ]\)/-\1 /g
		s/-a/-s -n -v -r -p -m/'`
		shift ;;
	*)	echo $usage >&2 ; exit 1 ;;
	esac
done

for opt in $opts
do
  case $opt in
  -s)	system="NEXTSTEP" ;;
  -n)	node=`uuname -l` ;;
  -r)	release=`hostinfo | sed -n 's/.*NeXT Mach \([0-9\.]*\).*/\1/p'` ;;
  -m)	mach=`hostinfo | sed -n 's/.*Processor type: \([^ ]*\).*/\1/p'` ;;
  -p)	processor=`hostinfo | \
	sed -n 's/.*Processor type: [^ ]* (\([^)]*\).*/\1/p'` ;;
  -v)	version=`tail -1 /usr/lib/NextStep/software_version` ;;
  -i)	hostid=`hostid` ;;
  *)	echo Invalid option: $opt "\n"$usage >&2 ; exit 1 ;;
  esac
done

echo $system $node $version $release $processor $mach $hostid
