* 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, ul, and more" 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], "ucb")) {
} else if (eq(argv
[0], "local")) {
} else if (eq(argv
[0], "new")) {
} else if (eq(argv
[0], "public")) {
} else if (eq(argv
[0], "sccs")) {
} else if (eq(argv
[0], "junk")) {
} 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
= "lun16823457psj";
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 | %s | %s | %s",
cp
, binpath(ssp
), binpath(ul
),
cflag
? binpath(cr3
) : binpath(more
));
sprintf(cmdbuf
, "%s -t -man %s %s | %s | %s -t", "/usr/bin/troff",
libpath(tmac
/tmac
.vcat
), cp
, libpath(vsort
), binpath(vpr
));