sbase/rm.c
FRIGN e60885699c Fix return values in rm(1) and mv(1)
by setting rm_status to 1 if removing 1 file in the list fails.
Extend this to mv_status in mv(1).
2015-01-30 12:45:54 +01:00

46 lines
601 B
C

/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include "fs.h"
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s [-f | -i] [-Rr] file ...\n", argv0);
}
int
main(int argc, char *argv[])
{
ARGBEGIN {
case 'f':
rm_fflag = 1;
break;
case 'i':
rm_fflag = 0;
break;
case 'R':
case 'r':
rm_rflag = 1;
break;
default:
usage();
} ARGEND;
if (argc < 1) {
if (!rm_fflag)
usage();
else
return 0;
}
for (; argc > 0; argc--, argv++)
rm(argv[0]);
return rm_status;
}