From: Sami Kerola Date: Sat, 7 Feb 2015 21:10:51 +0000 (+0000) Subject: whereis: tell when mandatory option is missing X-Git-Tag: v2.27-rc1~416 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3d29ee0c7bc638d27666809e02245cacfa031e3;p=thirdparty%2Futil-linux.git whereis: tell when mandatory option is missing The list is terminated by any arbitrary option, but to be simple when none is specified complain about -f being missing. Reviewed-by: Benno Schulenberg Reviewed-by: Karel Zak Signed-off-by: Sami Kerola --- diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 9fc5ee7ee8..6e23f7aa11 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -495,7 +495,7 @@ int main(int argc, char **argv) { struct wh_dirlist *ls = NULL; int want = ALL_DIRS; - int i, want_resetable = 0; + int i, want_resetable = 0, opt_f_missing = 0; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -540,9 +540,11 @@ int main(int argc, char **argv) switch (*arg) { case 'f': + opt_f_missing = 0; break; case 'u': uflag = 1; + opt_f_missing = 0; break; case 'B': if (*(arg + 1)) @@ -551,6 +553,7 @@ int main(int argc, char **argv) free_dirlist(&ls, BIN_DIR); construct_dirlist_from_argv( &ls, &i, argc, argv, BIN_DIR); + opt_f_missing = 1; break; case 'M': if (*(arg + 1)) @@ -559,6 +562,7 @@ int main(int argc, char **argv) free_dirlist(&ls, MAN_DIR); construct_dirlist_from_argv( &ls, &i, argc, argv, MAN_DIR); + opt_f_missing = 1; break; case 'S': if (*(arg + 1)) @@ -567,6 +571,7 @@ int main(int argc, char **argv) free_dirlist(&ls, SRC_DIR); construct_dirlist_from_argv( &ls, &i, argc, argv, SRC_DIR); + opt_f_missing = 1; break; case 'b': if (want_resetable) { @@ -574,6 +579,7 @@ int main(int argc, char **argv) want_resetable = 0; } want = want == ALL_DIRS ? BIN_DIR : want | BIN_DIR; + opt_f_missing = 0; break; case 'm': if (want_resetable) { @@ -581,6 +587,7 @@ int main(int argc, char **argv) want_resetable = 0; } want = want == ALL_DIRS ? MAN_DIR : want | MAN_DIR; + opt_f_missing = 0; break; case 's': if (want_resetable) { @@ -588,6 +595,7 @@ int main(int argc, char **argv) want_resetable = 0; } want = want == ALL_DIRS ? SRC_DIR : want | SRC_DIR; + opt_f_missing = 0; break; case 'l': list_dirlist(ls); @@ -607,5 +615,7 @@ int main(int argc, char **argv) } free_dirlist(&ls, ALL_DIRS); + if (opt_f_missing) + errx(EXIT_FAILURE, _("option -f is missing")); return EXIT_SUCCESS; }