abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 8f80aa8044d7ecf0e43a0294a09007d056b20e4c
parent c33ee37b435bcdabe9022d10a56da97e531bbad3
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 16 May 2018 10:44:37 +0200

Do not implicilty enable passthrough mode if no session name is given

Even when no session name was provided the passthrough flag was still
implicitly enabled in case stdin was not a terminal. This behavior
prevented the session list from being printed i.e.

  abduco < /dev/null

would not work as expected. Only enable implicit passthrough if stdin
is not a terminal *and* a session name is given.

Fix #34

Diffstat:
abduco.c | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/abduco.c b/abduco.c @@ -606,8 +606,6 @@ int main(int argc, char *argv[]) { server.name = basename(argv[0]); gethostname(server.host+1, sizeof(server.host) - 1); - passthrough = !isatty(STDIN_FILENO); - while ((opt = getopt(argc, argv, "aAclne:fpqrv")) != -1) { switch (opt) { case 'a': @@ -646,13 +644,6 @@ int main(int argc, char *argv[]) { } } - if (passthrough) { - if (!action) - action = 'a'; - quiet = true; - client.flags |= CLIENT_LOWPRIORITY; - } - /* collect the session name if trailing args */ if (optind < argc) server.session_name = argv[optind]; @@ -663,6 +654,16 @@ int main(int argc, char *argv[]) { else cmd = default_cmd; + if (server.session_name && !isatty(STDIN_FILENO)) + passthrough = true; + + if (passthrough) { + if (!action) + action = 'a'; + quiet = true; + client.flags |= CLIENT_LOWPRIORITY; + } + if (!action && !server.session_name) exit(list_session()); if (!action || !server.session_name)