int main(int argc, char *argv[]) { int ch, errors; int pflag; setlocale(LC_ALL, ""); pflag = 0; while ((ch = getopt(argc, argv, "p")) != -1) switch(ch) { case 'p': pflag = 1; break; default: usage(); } argc -= optind; argv += optind; if (argc == 0) usage(); for (errors = 0; *argv; argv++) { char *p; /* Delete trailing slashes, per POSIX. */ p = *argv + strlen(*argv); while (--p > *argv && *p == '/') ; *++p = '\0'; if (rmdir(*argv) < 0) { warn("%s", *argv); errors = 1; } else if (pflag) errors |= rm_path(*argv); } return (errors); }
int main(int argc, char **argv) { int ch, errors; int pflag; pflag = 0; while ((ch = getopt(argc, argv, "pv")) != -1) switch(ch) { case 'p': pflag = 1; break; case 'v': vflag = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc == 0) usage(); for (errors = 0; *argv; argv++) { if (rmdir(*argv) < 0) { warn("%s", *argv); errors = 1; } else { if (vflag) printf("removed: %s\n", *argv); if (pflag) errors |= rm_path(*argv); } } exit(errors); }
int main(int argc, char *argv[]) { int ch, errors, pflag; setprogname(argv[0]); (void)setlocale(LC_ALL, ""); if (fsu_mount(&argc, &argv, MOUNT_READWRITE) != 0) errx(-1, NULL); pflag = 0; while ((ch = getopt(argc, argv, "p")) != -1) switch(ch) { case 'p': pflag = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc == 0) usage(); for (errors = 0; *argv; argv++) { /* We rely on the kernel to ignore trailing '/' characters. */ if (rmdir(*argv) < 0) { warn("%s", *argv); errors = 1; } else if (pflag) errors |= rm_path(*argv); } exit(errors); /* NOTREACHED */ }