From 636435e5c25d39fc5d52edf936e8e7a410b31b1a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 7 Mar 1995 22:31:01 +0000 Subject: (decode_switches): If non-option arg is "-", ignore it. --- main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 43a6b89..29615e0 100644 --- a/main.c +++ b/main.c @@ -1223,30 +1223,31 @@ decode_switches (argc, argv, env) /* Reset getopt's state. */ optind = 0; - c = 0; while (optind < argc) { + /* Parse the next argument. */ + c = getopt_long (argc, argv, options, long_options, (int *) 0); if (c == EOF) { /* There are no more options according to getting getopt, but there are some arguments left. Since we have asked for non-option arguments to be returned in order, I think this only happens when there is a "--" argument to prevent later - argument from being options. Since getopt has finished its + arguments from being options. Since getopt has finished its job, just update its state variables for the next argument and set C as if it had returned 1, indicating a non-option argument. */ optarg = argv[optind++]; c = 1; } - else - /* Parse the next argument. */ - c = getopt_long (argc, argv, options, long_options, (int *) 0); if (c == 1) { /* Non-option argument. It might be a variable definition. */ struct variable *v; + if (optarg[0] == '-' && optarg[1] == '\0') + /* Ignore plain `-' for compatibility. */ + continue; v = try_variable_definition ((char *) 0, 0, optarg, o_command); if (v != 0) { -- cgit v1.2.3