1#!/bin/mksh
2
3args=`getopt amnr $*`
4if [ $? != 0 ]
5then
6         echo 'Usage: uname -[arn]'
7         exit 2
8fi
9           set -- $args
10           # You cannot use the set command with a backquoted getopt directly,
11           # since the exit code from getopt would be shadowed by those of set,
12           # which is zero by definition.
13           for i
14           do
15                   case "$i"
16                   in
17                           -a|-r|-m|-n)
18                                   sflags="${i#-}$sflags";
19                                   shift;;
20                           --)
21                                   shift; break;;
22                   esac
23           done
24#           echo single-char flags: "'"$sflags"'"
25#           echo oarg is "'"$oarg"'"
26
27if [ -z $sflags ]; then
28        echo "FreeBSD"
29else
30if [ $sflags == 'm' ]; then
31        /usr/bin/uname -m
32fi
33if [ $sflags == 'n' ]; then
34        /usr/bin/uname -n
35fi
36if [ $sflags == 'r' ]; then
37        echo '11.4-RELEASE'
38fi
39if [ $sflags == 'a' ]; then
40        echo "FreeBSD `/usr/bin/uname -n` 11.4-RELEASE FreeBSD 11.4-RELEASE GENERIC `/usr/bin/uname -m`"
41fi
42fi
43