diff options
author | Sami Kerola <kerolasa@iki.fi> | 2015-02-07 21:10:51 +0000 |
---|---|---|
committer | Sami Kerola <kerolasa@iki.fi> | 2015-03-03 19:35:27 +0000 |
commit | a3d29ee0c7bc638d27666809e02245cacfa031e3 (patch) | |
tree | 2c1dde57205af316bff43857646b3eb1e6bac24d | |
parent | f71d1104df68e9ab7f06878c1c324566721acd66 (diff) | |
download | util-linux-playground-a3d29ee0c7bc638d27666809e02245cacfa031e3.tar.gz |
whereis: tell when mandatory option is missing
The <dirs> list is terminated by any arbitrary option, but to be simple
when none is specified complain about -f being missing.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r-- | misc-utils/whereis.c | 12 |
1 files changed, 11 insertions, 1 deletions
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; } |