[net.unix-wizards] tar "t" option

wapd (04/14/83)

	There was a query about 2 weeks ago about the TAR "T" option.
I responded saying that Unix Support had found that the code for it
didn't even exist.

	Someone has sent mail to me saying that the code DOES exist
in 4.1BSD.  I was speaking of 4.0/5.0 USG Unix, and may have neglected
to say so.

						Bill Dietrich
						houxj!wapd

borman (04/20/83)

Ah, yes, the missing code for the "t" option of tar(1).  We are running
V7, and this past summer on of my fellow workers complained about
the "t" option not working.  I went in, found out that the code didn't
exist, so I wrote the stuff.  It's not that much to add, my fixes follow.
We have been running for months and no one has complained.
		-Dave Borman, ihnp4!stolaf!borman

*** tar.org	Tue Apr 19 20:10:58 1983
--- tar.c	Fri May 21 16:54:17 1982
***************
*** 4,9
   * tar - tape archiver
   */
  
  
  #include <stdio.h>
  #include <sys/types.h>

--- 4,12 -----
   * tar - tape archiver
   */
  
+ #define	T_FIX		/* Modification so that the t flag will only print  */
+ 			/* the entries of the files listed, and all the files */
+ 			/* if none are listed.  DAB  5-21-81	*/
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 194,199
  			fprintf(stderr, "tar: cannot open %s\n", usefile);
  			done(1);
  		}
  		dotable();
  	}
  	else

--- 197,205 -----
  			fprintf(stderr, "tar: cannot open %s\n", usefile);
  			done(1);
  		}
+ #ifdef	T_FIX
+ 		dotable(argv);
+ #else
  		dotable();
+ #endif	T_FIX
  	}
***************
*** 524,529
  	}
  }
  
  dotable()
  {
  	register char	**cp;

--- 531,540 -----
  	}
  }
  
+ #ifdef	T_FIX
+ dotable(argv)
+ char	**argv;
+ #else
  dotable()
+ #endif	T_FIX
  {
  	register char	**cp;
  	for (;;) {
***************
*** 531,536
  		getdir();
  		if (endtape())
  			break;
  		if (vflag)
  			longt(&stbuf);
  		printf("%s", dblock.dbuf.name);

--- 543,559 -----
  		getdir();
  		if (endtape())
  			break;
+ #ifdef	T_FIX
+ 		if( *argv != 0 ){
+ 			for( cp = argv; *cp; cp++)
+ 				if( prefix( *cp, dblock.dbuf.name) )
+ 					break;
+ 			if ( !*cp ){
+ 				passtape();
+ 				continue;
+ 			}
+ 		}
+ #endif	T_FIX
  		if (vflag)
  			longt(&stbuf);
  		printf("%s", dblock.dbuf.name);