Re: problem with man|head (not related to new kernels)

Jon Tombs (jon@gte.esi.us.es)
Fri, 16 Feb 1996 16:40:25 +0100 (MET)


Paul Matthews said:
>
> Trevor Johnson writes:
> > When I do
> >
> > man X|head>~/tempfile
> >
> > I get:
> >
> > Error executing formatting or display command.
> > System command exited with status 36096.
> > No manual entry for Xsecurity
> >

man-1.4d,e,f are broken in this respect, I patched localy my copy to use
isatty() on stdin and stdout and to not try ioctl() on stdin, or use
a pager on stdout when they are not ttys. Also on success man returns 1
not 0.

Here is a simple patch for somebody to clean up and send to the man
mantainers.

--- man.c Sun Jan 7 19:20:59 1996
+++ man.c.jon Fri Feb 9 21:07:29 1996
@@ -119,13 +119,14 @@
#ifdef TIOCGWINSZ
{
struct winsize wsz;
-
+ if (isatty(0) && isatty(1)) {
if(ioctl(0, TIOCGWINSZ, &wsz))
perror("TIOCGWINSZ failed\n");
else if(wsz.ws_col) {
line_length = wsz.ws_col;
return;
}
+ }
}
#endif
if ((cp = getenv ("COLUMNS")) != NULL && (width = atoi(cp)) > 0)
@@ -292,12 +293,18 @@
if (access (file, R_OK) == 0 && different_cat_file(file)) {
char *expander = get_expander (file);

- if (expander != NULL && expander[0] != 0)
- sprintf (command, "%s %s | %s", expander, file, pager);
- else
- sprintf (command, "%s %s", pager, file);
-
+ if (expander != NULL && expander[0] != 0) {
+ if (isatty(1) )
+ sprintf (command, "%s %s | %s", expander, file, pager);
+ else
+ sprintf (command, "%s %s", expander, file);
+ } else {
+ if (isatty(1) )
+ sprintf (command, "%s %s", pager, file);
+ else
+ sprintf (command, "cat %s", file);
found = !do_system_command (command, 0);
+ }
}
return found;
}
@@ -1196,5 +1203,5 @@
}
}
}
- return status;
+ return status -1;
}

-- 
Jon. <jon@gte.esi.us.es, http://www.esi.us.es/~jon>