Add explicit option for command pass through

This allows commands to be send interactively (i.e. when stdin refers
to a terminal). Also imply attach action if none is given, hence:

    $ abduco -p session
    cowsay hi
    ^D

can also be used to send input to a session.
This commit is contained in:
Marc André Tanner 2018-03-17 12:29:31 +01:00
parent c901f2bbb8
commit fd34b98db7
2 changed files with 17 additions and 4 deletions

View File

@ -77,8 +77,9 @@ domain socket representing a session is deleted, sending
.BR SIGUSR1
to the server process will recreate it.
If standard input does not refer to a terminal, its content is passed
through to the underlying session.
If standard input does not refer to a terminal (or the
.B -p
option was given), its content is passed through to the underlying session.
.SH OPTIONS
If no command line arguments are given all currently active sessions are
printed sorted by their respective creation date. Lines starting with an
@ -120,6 +121,13 @@ Attach with the lowest priority, meaning this client will be the last to control
.TP
.BI \-q
Be quiet, do not print informative messages.
.TP
.BI \-p
Pass through content of standard input to the session. Implies the
.B \-q
and
.B \-l
options.
.SH EXAMPLE
Start a new session (assuming
.BR dvtm(1)

View File

@ -222,7 +222,7 @@ static void die(const char *s) {
}
static void usage(void) {
fprintf(stderr, "usage: abduco [-a|-A|-c|-n] [-r] [-q] [-l] [-f] [-e detachkey] name command\n");
fprintf(stderr, "usage: abduco [-a|-A|-c|-n] [-p] [-r] [-q] [-l] [-f] [-e detachkey] name command\n");
exit(EXIT_FAILURE);
}
@ -590,7 +590,7 @@ int main(int argc, char *argv[]) {
passthrough = !isatty(STDIN_FILENO);
while ((opt = getopt(argc, argv, "aAclne:fqrv")) != -1) {
while ((opt = getopt(argc, argv, "aAclne:fpqrv")) != -1) {
switch (opt) {
case 'a':
case 'A':
@ -608,6 +608,9 @@ int main(int argc, char *argv[]) {
case 'f':
force = true;
break;
case 'p':
passthrough = true;
break;
case 'q':
quiet = true;
break;
@ -626,6 +629,8 @@ int main(int argc, char *argv[]) {
}
if (passthrough) {
if (!action)
action = 'a';
quiet = true;
client.flags |= CLIENT_LOWPRIORITY;
}