Diff between 9cafbbb18150df2ecddd78bfbdf189fd3a05a479 and f718b35b1bd9079fafd1f56f66da3e8d2641c5ce

Changed Files

File Additions Deletions Status
src/shared/shell.c +8 -1 modified

Full Patch

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 1fec58d..3aabda7 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -787,7 +787,7 @@ static void usage(int argc, char **argv, const struct bt_shell_opt *opt)
 
 void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
 {
-	int c, index = 0;
+	int c, index = -1;
 	struct option options[256];
 	char optstr[256];
 	size_t offset;
@@ -817,6 +817,13 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
 			data.timeout = atoi(optarg);
 			break;
 		default:
+			if (index < 0) {
+				for (index = 0; options[index].val; index++) {
+					if (c == options[index].val)
+						break;
+				}
+			}
+
 			if (c != opt->options[index - offset].val) {
 				usage(argc, argv, opt);
 				exit(EXIT_SUCCESS);