#include "V.h"
#include "sys_stat.h"
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*    Rm file...                                                                *
* Remove  files by renaming them.  We add '-' to the name, and we make a check *
* for the target existing, recursively removing it, too.  The result is a list *
* of files with more and more hyphens on the end of their names.               *
*                                                                              *
* The BACKUPS environment variable, if it exists and is a number, is the limit *
* to the number of backups that will be made; the default is 8.                *
*                                                                              *
* A difference from /bin/rm is that this program doesn't  consider  a  missing *
* file  to  be an error.  A nonzero exit status is given if there are bpfailed *
* due to permission problems, but no-such-file is not an error.                *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
extern int bpfailed;	/* Number of removes that fail */
extern int backups;		/* Limit to bpdepth of backups */

int main(ac,av)
	char**av;
{	int   a;
	char *p;

	Vinit(ac,av);
	if (p = Getenv("BACKUPS"))
		sscanf(p,"%d",&backups);
	V3 "Vlvl: %d.",Vlvl D;
	V3 "backups:%d.",backups D;
	for (a=1; a<ac; a++) {
		V2 "File \"%s\"",av[a] D;
		Backup(av[a]);
	}
	exit(bpfailed);	/* Always report success */
}
