Mercurial > dropbear
comparison cli-runopts.c @ 1171:c745f720ae2e
Fix flags after the hostname
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 23 Nov 2015 22:47:43 +0800 |
parents | ff9bd50f1457 |
children | 978887222d29 |
comparison
equal
deleted
inserted
replaced
1170:ff9bd50f1457 | 1171:c745f720ae2e |
---|---|
175 opts.keepalive_secs = DEFAULT_KEEPALIVE; | 175 opts.keepalive_secs = DEFAULT_KEEPALIVE; |
176 opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT; | 176 opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT; |
177 | 177 |
178 fill_own_user(); | 178 fill_own_user(); |
179 | 179 |
180 for (i = 1; i < (unsigned int)argc && argv[i][0] == '-'; i++) { | 180 for (i = 1; i < (unsigned int)argc; i++) { |
181 /* Handle non-flag arguments such as hostname or commands for the remote host */ | |
182 if (argv[i][0] != '-') | |
183 { | |
184 if (host_arg == NULL) { | |
185 host_arg = argv[i]; | |
186 continue; | |
187 } | |
188 /* Commands to pass to the remote host. No more flag handling, | |
189 commands are consumed below */ | |
190 break; | |
191 } | |
192 | |
193 /* Begins with '-' */ | |
181 opt = OPT_OTHER; | 194 opt = OPT_OTHER; |
182 for (j = 1; (c = argv[i][j]) != '\0' && !next && opt == OPT_OTHER; j++) { | 195 for (j = 1; (c = argv[i][j]) != '\0' && !next && opt == OPT_OTHER; j++) { |
183 switch (c) { | 196 switch (c) { |
184 case 'y': /* always accept the remote hostkey */ | 197 case 'y': /* always accept the remote hostkey */ |
185 if (cli_opts.always_accept_key) { | 198 if (cli_opts.always_accept_key) { |
346 } | 359 } |
347 | 360 |
348 /* Done with options/flags; now handle the hostname (which may not | 361 /* Done with options/flags; now handle the hostname (which may not |
349 * start with a hyphen) and optional command */ | 362 * start with a hyphen) and optional command */ |
350 | 363 |
351 if (i >= (unsigned int)argc) { /* missing hostname */ | 364 if (host_arg == NULL) { /* missing hostname */ |
352 printhelp(); | 365 printhelp(); |
353 exit(EXIT_FAILURE); | 366 exit(EXIT_FAILURE); |
354 } | 367 } |
355 host_arg = argv[i++]; | |
356 TRACE(("host is: %s", host_arg)) | 368 TRACE(("host is: %s", host_arg)) |
357 | 369 |
358 if (i < (unsigned int)argc) { | 370 if (i < (unsigned int)argc) { |
359 /* Build the command to send */ | 371 /* Build the command to send */ |
360 cmdlen = 0; | 372 cmdlen = 0; |