[1808] in Athena Bugs

home help back first fref pref prev next nref lref last post

bug in BSD man(1)

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Thu Feb 23 02:16:12 1989

Date: Thu, 23 Feb 89 02:15:50 EST
From: Jonathan I. Kamens <jik@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU, bugs@berkeley.edu, bsd-bugs@okeeffe.berkeley.edu

The BSD man program compares argv[0] to "whatis" and "apropos" to
determine if it is supposed to perform those functions rather than
displaying a manual entry.  However, it does not take into account the
fact that the user may specify the path explicitly, e.g.
"/usr/ucb/whatis."  The patch below fixes this problem.

Your line numbers may vary.

Jonathan Kamens			              USnail:
MIT Project Athena				410 Memorial Drive, No. 223F
jik@Athena.MIT.EDU				Cambridge, MA 02139-4318
Office: 617-253-4261			      Home: 617-225-8218

*** /source/4.3/ucb/man.c	Sun Jan  8 00:45:42 1989
--- /mit/jik/src/man/man.c	Thu Feb 23 02:04:18 1989
***************
*** 80,95 ****
  	char *argv[];
  {
  	char *mp;
! 
  	if ((mp = getenv("MANPATH")) != NULL)
  		manpath = mp;
  	umask(0);
  	mypid = getpid();
! 	if (strcmp(argv[0], "apropos") == 0) {
  		runpath(argc-1, argv+1, apropos);
  		exit(0);
  	}
! 	if (strcmp(argv[0], "whatis") == 0) {
  		runpath(argc-1, argv+1, whatis);
  		exit(0);
  	}
--- 80,101 ----
  	char *argv[];
  {
  	char *mp;
! 	char *whoami;
! 	
  	if ((mp = getenv("MANPATH")) != NULL)
  		manpath = mp;
  	umask(0);
  	mypid = getpid();
! 	whoami = rindex(argv[0], '/');
! 	if (whoami)
! 	     whoami++;
! 	else
! 	     whoami = argv[0];
! 	if (strcmp(whoami, "apropos") == 0) {
  		runpath(argc-1, argv+1, apropos);
  		exit(0);
  	}
! 	if (strcmp(whoami, "whatis") == 0) {
  		runpath(argc-1, argv+1, whatis);
  		exit(0);
  	}

home help back first fref pref prev next nref lref last post