/* Copyright (c) 1979 Regents of the University of California */
* man - intelligent man command
* Author: Bill Joy UCB August 25, 1977
* Man is an intelligent man command which obviates the need to know
* section numbers in the manual. Also if the standard output is a teletype and
* the option - is not given we pipe through "ssp and cr3" to eliminate piled
#define eq(a,b) (strcmp(a,b) == 0)
fprintf(stderr
, "Usage: man [ section ] name ...\n");
if (chdir("/usr/man") < 0) {
fprintf(stderr
, "Can't chdir to /usr/man.\n");
while (argc
> 0 && argv
[0][0] == '-') {
if (troffit
== 0 && nocr3
== 0 && !isatty(1))
if (eq(argv
[0], "new") || eq(argv
[0], "ucb")) {
} else if (eq(argv
[0], "public")) {
} else if (eq(argv
[0], "sccs")) {
} else if (argv
[0][0] >= '0' && argv
[0][0] <= '9' && (argv
[0][1] == 0 || argv
[0][2] == 0)) {
fprintf(stderr
, "But what do you want from section %s?\n", argv
[-1]);
manual(section
, argv
[0]);
char *sp
= "u16823457ps";
for (section
= *sp
++; section
; section
= *sp
++) {
if (stat(work
, &stbuf
) >= 0)
if (work
[last
] == '1' || work
[last
] == '3') {
cp
= work
[last
] == '1' ? "mcg" : "xmsf";
if (stat(work
, &stbuf
) >= 0) {
printf("No manual entry for %s.\n", name
);
printf("No entry for %s in section %c of the manual.\n", name
, sec
);
if (stat(work
, &stbuf
) < 0) {
if ((section
== '1' || section
== '3') && subsec
== 0) {
printf("No entry for %s in section %c", name
, section
);
printf(" of the manual.\n");
sprintf(cmdbuf
, "nroff -h -man %s", cp
);
sprintf(cmdbuf
, "nroff -h -man %s | /usr/ucb/ssp | /usr/ucb/cr3", cp
);
sprintf(cmdbuf
, "/usr/ucb/troff -t -man /usr/lib/tmac/tmac.vcat %s | /usr/ucb/vsort | /usr/ucb/vpr -t", cp
);