Skip to contentSkip to conversation

shared/shell: Fix non-interactive mode with no input stream

PATCH New Tarvi Verro 1 participant 1 message Apr 21, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shared/shell: Fix non-interactive mode with no input stream

When the input stream doesn't support epoll, the non-interactive mode should still print its output.

Showed up when a script was run as a systemd service. For testing consider that the following command should report a version string:

btmgmt version < /dev/null
Version 5.49

---
 src/shared/shell.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/shared/shell.c +3 -3
index e7f17e021..aa20c30f7 100644
@@ -460,9 +460,6 @@ void bt_shell_printf(const char *fmt, ...)
 	char *saved_line;
 	int saved_point;
 
-	if (!data.input)
-		return;
-
 	if (data.mode) {
 		va_start(args, fmt);
 		vprintf(fmt, args);
@@ -470,6 +467,9 @@ void bt_shell_printf(const char *fmt, ...)
 		return;
 	}
 
+	if (!data.input)
+		return;
+
 	save_input = !RL_ISSTATE(RL_STATE_DONE);
 
 	if (save_input) {
Signature · 1 line
2.17.0