A useful aid.. Add support for:

%r:	current release
	%m:	machine architecture type (i386 for now)
	%s:	OS name (FreeBSD)

from uname() in banner string.
This commit is contained in:
Jordan K. Hubbard 1995-08-01 13:12:24 +00:00
parent 156547674a
commit 4d7ccc95b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9839
2 changed files with 35 additions and 4 deletions

View File

@ -220,10 +220,15 @@ and
.Em \&lm
may include the character sequence
.Em \&%h
or
to include the hostname,
.Em \&%t
to obtain
the hostname or tty name respectively.
to obtain the tty name,
.Em \&%s
to obtain the OS type (FreeBSD),
.Em \&%r
to obtain the OS release string or
.Em \&%m
to obtain the machine architecture type.
.Pf ( Em %%
obtains a single '%' character.)
The hostname is normally obtained from the system,

View File

@ -56,6 +56,7 @@ static char sccsid[] = "@(#)main.c 5.16 (Berkeley) 3/27/91";
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
#include "gettytab.h"
#include "pathnames.h"
@ -454,6 +455,7 @@ putf(cp)
break;
case 'h':
case 'n':
puts(editedhost);
break;
@ -464,8 +466,32 @@ putf(cp)
(void)time(&t);
(void)strftime(db, sizeof(db), fmt, localtime(&t));
puts(db);
break;
}
break;
case 's': {
struct utsname name;
if (uname(&name) != -1)
puts(name.sysname);
}
break;
case 'r': {
struct utsname name;
if (uname(&name) != -1)
puts(name.release);
}
break;
case 'm': {
struct utsname name;
if (uname(&name) != -1)
puts(name.machine);
}
break;
case '%':
putchr('%');