summaryrefslogtreecommitdiff
path: root/src/echo.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-01-13 21:59:35 -0700
committerEric Blake <ebb9@byu.net>2009-01-14 14:32:13 -0700
commit7b1967351c80c56abc5b8c6c4a66ffba80050c5c (patch)
tree50837c792ec3c309bf36f03db3b160b3750832b6 /src/echo.c
parentd01338eb3d30e5634f1b4d4179c229f54eea0b44 (diff)
downloadcoreutils-7b1967351c80c56abc5b8c6c4a66ffba80050c5c.tar.xz
test, echo, printf: don't accept option abbreviation
* src/test.c (main): Directly parse accepted options, thus avoiding abbreviations. * src/echo.c (main): Likewise. * src/printf.c (main): Likewise.
Diffstat (limited to 'src/echo.c')
-rw-r--r--src/echo.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/echo.c b/src/echo.c
index c4b7ca939..91cce86d6 100644
--- a/src/echo.c
+++ b/src/echo.c
@@ -124,9 +124,20 @@ main (int argc, char **argv)
atexit (close_stdout);
- if (allow_options)
- parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
- usage, AUTHORS, (char const *) NULL);
+ /* We directly parse options, rather than use parse_long_options, in
+ order to avoid accepting abbreviations. */
+ if (allow_options && argc == 2)
+ {
+ if (STREQ (argv[1], "--help"))
+ usage (EXIT_SUCCESS);
+
+ if (STREQ (argv[1], "--version"))
+ {
+ version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
+ (char *) NULL);
+ exit (EXIT_SUCCESS);
+ }
+ }
--argc;
++argv;