char *cwd_only[2];
int max_depth_specified = 0;
char **files;
+ int fail;
/* Bit flags that control how nftw works. */
int ftw_flags = FTW_DEPTH | FTW_PHYS | FTW_CHDIR;
human_output_opts = human_options (getenv ("DU_BLOCK_SIZE"), false,
&output_block_size);
+ fail = 0;
while ((c = getopt_long (argc, argv, "abchHklmsxB:DLSX:", long_options, NULL))
!= -1)
{
break;
case MAX_DEPTH_OPTION: /* --max-depth=N */
- /* FIXME: merely set `fail' here, in case there are
- additional invalid options */
- if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
- || tmp_long < 0 || tmp_long > INT_MAX)
- error (EXIT_FAILURE, 0, _("invalid maximum depth %s"),
- quote (optarg));
-
- max_depth_specified = 1;
- max_depth = (int) tmp_long;
+ if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) == LONGINT_OK
+ && 0 <= tmp_long && tmp_long <= INT_MAX)
+ {
+ max_depth_specified = 1;
+ max_depth = (int) tmp_long;
+ }
+ else
+ {
+ error (0, 0, _("invalid maximum depth %s"),
+ quote (optarg));
+ fail = 1;
+ }
break;
case 'm': /* obsolescent */
break;
case 'X':
- /* FIXME: merely set `fail' here, in case there are
- additional invalid options */
if (add_exclude_file (add_exclude, exclude, optarg,
EXCLUDE_WILDCARDS, '\n'))
- error (EXIT_FAILURE, errno, "%s", quotearg_colon (optarg));
+ {
+ error (0, errno, "%s", quotearg_colon (optarg));
+ fail = 1;
+ }
break;
case EXCLUDE_OPTION:
}
}
+ if (fail)
+ exit (EXIT_FAILURE);
+
if (opt_all && opt_summarize_only)
{
error (0, 0, _("cannot both summarize and show all entries"));