diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-11-01 23:05:29 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-11-01 23:05:29 +0000 |
commit | 99f09784cc98732a440de86bb99a46f11f7355d8 (patch) | |
tree | 2b38e662ba076bac4562dbddb0356ec3aa8b6fbb /src/tail.c | |
parent | 4fb9c70faf7888cf5d3a7bdf73fc1dbd7aa34c31 (diff) | |
download | coreutils-99f09784cc98732a440de86bb99a46f11f7355d8.tar.xz |
(parse_obsolete_option): Implement fix for "tail -c 2 FILE".
Diffstat (limited to 'src/tail.c')
-rw-r--r-- | src/tail.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/tail.c b/src/tail.c index 9c6b64e32..c9b0c4ac8 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++) { |