From: Eric Andersen Date: Thu, 6 Jun 2002 11:35:29 +0000 (-0000) Subject: last_patch41 from vodz to fix stty -F and similar X-Git-Tag: 0_60_4~175 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fc059090b6954348ee4510ff0dac097bf3a9b682;p=oweals%2Fbusybox.git last_patch41 from vodz to fix stty -F and similar --- diff --git a/coreutils/stty.c b/coreutils/stty.c index 2e00a496d..a67a17c0f 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -572,14 +572,34 @@ extern int main(int argc, char **argv) speed_was_set = 0; require_set_attr = 0; - k = optind; - while (k < argc) { + k = 0; + while (++k < argc) { int match_found = 0; int reversed = 0; int i; if (argv[k][0] == '-') { + char *find_dev_opt; + ++argv[k]; + + /* Handle "-a", "-ag", "-aF/dev/foo", "-aF /dev/foo", etc. + Find the options that have been parsed. This is really + gross, but it's needed because stty SETTINGS look like options to + getopt(), so we need to work around things in a really horrible + way. If any new options are ever added to stty, the short option + MUST NOT be a letter which is the first letter of one of the + possible stty settings. + */ + find_dev_opt = strchr(argv[k], 'F'); /* find -*F* */ + if(find_dev_opt) { + if(find_dev_opt[1]==0) /* -*F /dev/foo */ + k++; /* skip /dev/foo */ + continue; /* else -*F/dev/foo - no skip */ + } + if(argv[k][0]=='a' || argv[k][0]=='g') + continue; + /* Is not options - is reverse params */ reversed = 1; } for (i = 0; i < NUM_mode_info; ++i) @@ -661,7 +681,6 @@ extern int main(int argc, char **argv) } else error_msg_and_die("invalid argument `%s'", argv[k]); } - k++; } if (require_set_attr) {