Compare commits

..

No commits in common. "080e3e9e4431be3631deebafdcb29111c8574e64" and "14480decc77867c27c2eeeb8fca83ec4b78fcaf2" have entirely different histories.

2 changed files with 24 additions and 23 deletions

View File

@ -101,7 +101,8 @@ static int client_mainloop(void) {
if (client_recv_packet(&pkt)) {
switch (pkt.type) {
case MSG_CONTENT:
write_all(STDOUT_FILENO, pkt.u.msg, pkt.len);
if (!passthrough)
write_all(STDOUT_FILENO, pkt.u.msg, pkt.len);
break;
case MSG_RESIZE:
client.need_resize = true;

44
splex.c
View File

@ -122,7 +122,7 @@ typedef struct {
static Server server = { .running = true, .exit_status = -1, .host = "@localhost" };
static Client client;
static struct termios orig_term, cur_term;
static bool has_term, alternate_buffer, quiet;
static bool has_term, alternate_buffer, quiet, passthrough;
static struct sockaddr_un sockaddr = {
.sun_family = AF_UNIX,
@ -225,6 +225,7 @@ static void die(const char *s) {
static void usage(void) {
fprintf(stderr, "usage: abduco [-a|-A|-c|-n] [-p] [-r] [-q] [-l] [-f] [-e detachkey] name command\n");
exit(EXIT_FAILURE);
}
static bool xsnprintf(char *buf, size_t size, const char *fmt, ...) {
@ -602,7 +603,7 @@ int main(int argc, char *argv[]) {
server.name = basename(argv[0]);
gethostname(server.host+1, sizeof(server.host) - 1);
while ((opt = getopt(argc, argv, "aAchlne:fqrvz")) != -1) {
while ((opt = getopt(argc, argv, "aAclne:fpqrv")) != -1) {
switch (opt) {
case 'a':
case 'A':
@ -611,10 +612,8 @@ int main(int argc, char *argv[]) {
action = opt;
break;
case 'e':
if (!optarg) {
if (!optarg)
usage();
exit(EXIT_FAILURE);
}
if (optarg[0] == '^' && optarg[1])
optarg[0] = CTRL(optarg[1]);
KEY_DETACH = optarg[0];
@ -622,27 +621,23 @@ int main(int argc, char *argv[]) {
case 'f':
force = true;
break;
case 'h':
usage();
exit(EXIT_SUCCESS);
case 'l':
list_session();
exit(EXIT_SUCCESS);
case 'p':
passthrough = true;
break;
case 'q':
quiet = true;
break;
case 'r':
client.flags |= CLIENT_READONLY;
break;
case 'v':
puts("splex-0.1, based on abduco-"VERSION" by Marc André Tanner");
exit(EXIT_SUCCESS);
case 'z':
case 'l':
client.flags |= CLIENT_LOWPRIORITY;
break;
case 'v':
puts("abduco-"VERSION" © 2013-2018 Marc André Tanner");
exit(EXIT_SUCCESS);
default:
usage();
exit(EXIT_FAILURE);
}
}
@ -656,17 +651,22 @@ int main(int argc, char *argv[]) {
else
cmd = default_cmd;
if (!isatty(STDIN_FILENO))
die("STDIN is not a tty");
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) {
if (!action || !server.session_name)
usage();
exit(EXIT_FAILURE);
}
if (tcgetattr(STDIN_FILENO, &orig_term) != -1) {
if (!passthrough && tcgetattr(STDIN_FILENO, &orig_term) != -1) {
server.term = orig_term;
has_term = true;
}