From 08f38fd93040bb4a6f0c3fe333dccb6f58d66175 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 5 Jul 1997 22:50:32 +0000 Subject: [PATCH] (parse_obsolescent_option): If POSIXLY_CORRECT is set, give a diagnostic and fail when there are two or more non-option arguments. --- src/tail.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/tail.c b/src/tail.c index e4b90e04e..0ca26b62f 100644 --- a/src/tail.c +++ b/src/tail.c @@ -88,7 +88,7 @@ /* Size of atomic reads. */ #ifndef BUFSIZ -#define BUFSIZ (512 * 8) +# define BUFSIZ (512 * 8) #endif /* If nonzero, interpret the numeric argument as the number of lines. @@ -875,7 +875,8 @@ parse_obsolescent_option (int argc, const char *const *argv, int t_forever; /* With the obsolescent form, there is one option string and - (technically) at most one file argument. But we allow two or more. */ + (technically) at most one file argument. But we allow two or more + by default. */ if (argc < 2) return 0; @@ -978,6 +979,20 @@ parse_obsolescent_option (int argc, const char *const *argv, { if (argc > 3) { + int posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL); + + /* When POSIXLY_CORRECT is set, enforce the `at most one + file argument' requirement. */ + if (posix_pedantic) + { + error (0, 0, _("\ +too many arguments; When using tail's obsolescent option syntax (%s)\n\ +there may be no more than one file argument. Use the equivalent -n or -c\n\ +option instead."), argv[1]); + *fail = 1; + return 1; + } + error (0, 0, _("\ Warning: it is not portable to use two or more file arguments with\n\ tail's obsolescent option syntax (%s). Use the equivalent -n or -c\n\