Subject: bin/5632: /usr/bin/what is for SCCS, not NetBSD & CVS
To: None <gnats-bugs@gnats.netbsd.org>
From: Jon Buller <jonb@metronet.com>
List: netbsd-bugs
Date: 06/20/1998 11:58:49
>Number:         5632
>Category:       bin
>Synopsis:       /usr/bin/what is for SCCS, not NetBSD & CVS
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 20 10:05:00 1998
>Last-Modified:
>Originator:     Jon Buller
>Organization:
	
>Release:        Jun 20, 1998
>Environment:
	
System: NetBSD bullbox 1.3.1 NetBSD 1.3.1 (BULLBOX) #0: Sun Mar 29 00:26:43 CST 1998 jonb@bullbox:/usr/src/sys/arch/pc532/compile/BULLBOX pc532


>Description:
	/usr/bin/what only looks for strings starting with @(#), but
	NetBSD uses CVS and starts the info text $NetBSD.
>How-To-Repeat:
	/usr/bin/what /bin/ls produces the following:

	/bin/ls
         	Copyright (c) 1989, 1993, 1994

>Fix:
	apply the following patch.  (It could use a backward compatibility
        flag for people using SCCS.)

diff -c what/what.1 /usr/src/usr.bin/what/what.1
*** what/what.1	Mon Oct 20 09:53:05 1997
--- /usr/src/usr.bin/what/what.1	Sat Jun 20 06:58:24 1998
***************
*** 33,70 ****
  .\"
  .\"     @(#)what.1	8.1 (Berkeley) 6/6/93
  .\"
! .Dd June 6, 1993
  .Dt WHAT 1
! .Os BSD 4
  .Sh NAME
  .Nm what
  .Nd "show what versions of object modules were used to construct a file"
  .Sh SYNOPSIS
  .Nm
  .Ar name Ar ...
  .Sh DESCRIPTION
  .Nm
  reads each file
  .Ar name
  and searches for sequences of the form
! .Dq \&@(#)
! as inserted by the source code control system.  It prints the remainder
! of the string following this marker, up to a null character, newline, double
! quote, or
! .Dq \&> character.
  .Sh BUGS
! As
! .Bx
! is not licensed to distribute
! .Tn SCCS
! this is a rewrite of the
! .Nm
! command which is part of
! .Tn SCCS ,
! and may not behave exactly the same as that
! command does.
  .Sh HISTORY
  The
  .Nm
  command appeared in
  .Bx 4.0 .
--- 33,70 ----
  .\"
  .\"     @(#)what.1	8.1 (Berkeley) 6/6/93
  .\"
! .Dd June 20, 1998
  .Dt WHAT 1
! .Os
  .Sh NAME
  .Nm what
  .Nd "show what versions of object modules were used to construct a file"
  .Sh SYNOPSIS
  .Nm
+ .Op Fl p Ar prefix
+ .Op Fl s Ar suffix
  .Ar name Ar ...
  .Sh DESCRIPTION
  .Nm
  reads each file
  .Ar name
  and searches for sequences of the form
! .Dq \&$NetBSD:\ 
! as inserted by the source code control system.  It prints the sequence
! until the trailing \&$
! character.
  .Sh BUGS
! The program should probably have some way to specify more that one
! valid suffix.  This would allow compatibility with the old SCCS specific
! version that used a null character, newline, double quote, or 
! .Dq \&>
! character as a suffix.  A backward compatibily flag probably wouldn't
! hurt, instead of forcing
! .Dq \&-p @(#)
! on a user.
  .Sh HISTORY
  The
  .Nm
  command appeared in
  .Bx 4.0 .
+ It was rewritten by Jon Buller for NetBSD 1.4
diff -c what/what.c /usr/src/usr.bin/what/what.c
*** what/what.c	Mon Oct 20 09:53:06 1997
--- /usr/src/usr.bin/what/what.c	Sat Jun 20 06:28:42 1998
***************
*** 51,56 ****
--- 51,59 ----
  void search __P((void));
  int main __P((int, char **));
  
+ char *prefix = "$NetBSD: ";
+ char *suffix = "$";
+ 
  /*
   * what
   */
***************
*** 63,69 ****
  	if (!*++argv) 
  		search();
  	else do {
! 		if (!freopen(*argv, "r", stdin)) {
  			perror(*argv);
  			exit(1);
  		}
--- 66,78 ----
  	if (!*++argv) 
  		search();
  	else do {
! 		if (!strcmp (*argv, "-p")) {
! 			prefix = *++argv;
! 		}
! 		else if (!strcmp (*argv, "-s")) {
! 			suffix = *++argv;
! 		}
! 		else if (!freopen(*argv, "r", stdin)) {
  			perror(*argv);
  			exit(1);
  		}
***************
*** 77,96 ****
  search()
  {
  	int c;
  
  	while ((c = getchar()) != EOF) {
! loop:		if (c != '@')
! 			continue;
! 		if ((c = getchar()) != '(')
! 			goto loop;
! 		if ((c = getchar()) != '#')
! 			goto loop;
! 		if ((c = getchar()) != ')')
! 			goto loop;
! 		putchar('\t');
! 		while ((c = getchar()) != EOF && c && c != '"' &&
! 		    c != '>' && c != '\n')
! 			putchar(c);
! 		putchar('\n');
  	}
  }
--- 86,106 ----
  search()
  {
  	int c;
+         char *p = prefix;
+ 	char *s = suffix;
  
  	while ((c = getchar()) != EOF) {
! 		if (c != *p++) p = prefix;
! 		if (!*p) {
! 			p = prefix;
! 			printf ("%s", prefix);
! 			while ((c = getchar()) != EOF) {
! 				if (c != *s++) s = suffix;
! 				putchar(c);
! 				if (!*s) break;
! 			}
! 			putchar('\n');
! 			s = suffix;
! 		}
  	}
  }
>Audit-Trail:
>Unformatted: