- while (argc-- > 0) {
- srcName = *(argv++);
- if (recursiveAction( srcName, recursiveFlag, TRUE, TRUE,
- fileAction, dirAction) == FALSE) {
- exit( FALSE);
+ /* Parse any options */
+ while (argc > 0 && stopIt == FALSE) {
+ if (**argv == '-') {
+ while (*++(*argv))
+ switch (**argv) {
+ case 'R':
+ case 'r':
+ recursiveFlag = TRUE;
+ break;
+ case 'f':
+ forceFlag = TRUE;
+ break;
+ case '-':
+ stopIt = TRUE;
+ break;
+ default:
+ usage(rm_usage);
+ }
+ argc--;
+ argv++;
+ }
+ else
+ break;
+ }
+
+ if (argc < 1 && forceFlag == FALSE) {
+ usage(rm_usage);
+ }
+
+ while (argc-- > 0) {
+ srcName = *(argv++);
+ if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
+ && errno == ENOENT) {
+ /* do not reports errors for non-existent files if -f, just skip them */
+ } else {
+ if (recursive_action(srcName, recursiveFlag, FALSE,
+ TRUE, fileAction, dirAction, NULL) == FALSE) {
+ status = EXIT_FAILURE;
+ }
+ }