shell: Set empty argument if optarg is NULL
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 29 Aug 2022 21:33:04 +0000 (14:33 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
This sets enmpty string ("") when argument don't set any optarg so the
application can tell when an option was set or not.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/shared/shell.c

index a83e2bd..4cf0cda 100644 (file)
@@ -1157,7 +1157,7 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
                                return;
                        }
 
-                       *opt->optarg[index - offset] = optarg;
+                       *opt->optarg[index - offset] = optarg ? : "";
                }
 
                index = -1;