From 8fe5dde4b83ed7c0859eb6eeb410ab38db9abb22 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Thu, 20 Apr 2023 17:28:39 +0200 Subject: [PATCH] Fix line termination for response wait feature The response wait feature waited for a line response, a string terminated with either CR or NL. However, some devices may send a CR and then their line content and then NL. This means tio will quit before receiving and printing the line response. To solve this we simply ignore the CR character and only consider lines terminated with a NL character. This should work for all devices as lines are AFAIK always terminated with either CRNL or a NL. --- man/tio.1.in | 4 ++-- src/tty.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/tio.1.in b/man/tio.1.in index 46bf144..83cf6b1 100644 --- a/man/tio.1.in +++ b/man/tio.1.in @@ -220,8 +220,8 @@ At present there is a hardcoded limit of 16 clients connected at one time. .TP .BR \-r ", " \-\-response-wait -Wait for line response then quit. A line is considered any string ending with -either CR or NL character. If no line is received tio will quit after response +Wait for line response then quit. A line is considered any string terminated +with a NL character. If no line is received tio will quit after response timeout. Any tio text is automatically muted when piping a string to tio while in diff --git a/src/tty.c b/src/tty.c index 54ea980..186fa77 100644 --- a/src/tty.c +++ b/src/tty.c @@ -1426,7 +1426,7 @@ int tty_connect(void) if (option.response_wait) { - if ((input_char == '\r') || (input_char == '\n')) + if (input_char == '\n') { tty_sync(fd); exit(EXIT_SUCCESS);