From 99f09784cc98732a440de86bb99a46f11f7355d8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 1 Nov 2005 23:05:29 +0000 Subject: [PATCH] (parse_obsolete_option): Implement fix for "tail -c 2 FILE". --- src/tail.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tail.c b/src/tail.c index 9c6b64e326..c9b0c4ac8d 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1363,7 +1363,7 @@ tail_file (struct File_spec *f, uintmax_t n_units) static bool parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) { - const char *p = argv[1]; + const char *p; const char *n_string; const char *n_string_end; bool obsolete_usage; @@ -1372,13 +1372,15 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) bool t_count_lines = true; bool t_forever = false; - /* With the obsolete form, there is one option string and - (technically) at most one file argument. But we allow two or more - by default. */ - if (argc < 2) + /* With the obsolete form, there is one option string and at most + one file argument. Watch out for "-" and "--", though. */ + if (! (argc == 2 + || (argc == 3 && ! (argv[2][0] == '-' && argv[2][1])) + || (3 <= argc && argc <= 4 && STREQ (argv[2], "--")))) return false; obsolete_usage = (posix2_version () < 200112); + p = argv[1]; switch (*p++) { -- 2.47.3