diff mbox series

[BlueZ,v2,6/7] shared/shell: Add function to handle early help calls

Message ID 20241022120051.123888-7-hadess@hadess.net (mailing list archive)
State Superseded
Headers show
Series Fix bluetoothctl --help hanging if daemon isn't running | expand

Commit Message

Bastien Nocera Oct. 22, 2024, 11:58 a.m. UTC
Add a function that would allow tools to exit after handling --help, so
as to avoid the daemon waiting to communicate with a D-Bus service that
might not be running.
---
 src/shared/shell.c | 10 ++++++++++
 src/shared/shell.h |  2 ++
 2 files changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 9ff774fe43a2..7107fb4c7776 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1694,3 +1694,13 @@  int bt_shell_get_timeout(void)
 {
 	return data.timeout;
 }
+
+void bt_shell_handle_non_interactive_help(void)
+{
+	if (!data.mode)
+		return;
+	if (data.argv[0] != cmplt)
+		return;
+	print_cmds();
+	exit(EXIT_SUCCESS);
+}
diff --git a/src/shared/shell.h b/src/shared/shell.h
index b03250cac80f..17277a601d3e 100644
--- a/src/shared/shell.h
+++ b/src/shared/shell.h
@@ -60,6 +60,8 @@  int bt_shell_exec(const char *input);
 void bt_shell_quit(int status);
 void bt_shell_noninteractive_quit(int status);
 
+void bt_shell_handle_non_interactive_help(void);
+
 bool bt_shell_set_menu(const struct bt_shell_menu *menu);
 
 bool bt_shell_add_submenu(const struct bt_shell_menu *menu);