mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Fix command-line tty-device|config parsing
Allow user to add options on both sides of the provided config argument. For example: $ tio -b 9600 am64-evm -e Before, tio only allowed adding arguments after the config argument. Implemented as simple as possible by introducing two stage option parsing.
This commit is contained in:
parent
bd5f542959
commit
a0d4be068b
5 changed files with 30 additions and 19 deletions
|
|
@ -351,7 +351,7 @@ void options_parse(int argc, char *argv[])
|
|||
|
||||
if (strlen(option.tty_device) == 0)
|
||||
{
|
||||
printf("Error: Missing device name\n");
|
||||
printf("Error: Missing device or config name\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -365,3 +365,16 @@ void options_parse(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void options_parse_final(int argc, char *argv[])
|
||||
{
|
||||
/* Preserve tty device which may have been set by configuration file */
|
||||
const char *tty_device = option.tty_device;
|
||||
|
||||
/* Do 2nd pass to override settings set by configuration file */
|
||||
optind = 1; // Reset option index to restart scanning of argv
|
||||
options_parse(argc, argv);
|
||||
|
||||
/* Restore tty device */
|
||||
option.tty_device = tty_device;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue