From 884ebb6dabe265ff67cfc75201263b3f3ef8ec99 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 3 Sep 2009 21:02:55 +0000 Subject: [PATCH] Sync OpenBSD patchset 309: Accept -l to make it easier for people who use tmux as a login shell to use $SHELL. Originally from martynas@, tweaked by me. --- cmd-server-info.c | 7 ++++--- tmux.1 | 8 ++++++-- tmux.c | 15 ++++++++++----- tmux.h | 3 ++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cmd-server-info.c b/cmd-server-info.c index 93f56e6f..eba89699 100644 --- a/cmd-server-info.c +++ b/cmd-server-info.c @@ -1,4 +1,4 @@ -/* $Id: cmd-server-info.c,v 1.26 2009-08-20 11:35:16 tcunha Exp $ */ +/* $Id: cmd-server-info.c,v 1.27 2009-09-03 21:02:55 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -68,8 +68,9 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx) *strchr(tim, '\n') = '\0'; ctx->print(ctx, "tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim); - ctx->print(ctx, "socket path %s, debug level %d%s", - socket_path, debug_level, be_quiet ? ", quiet" : ""); + ctx->print(ctx, "socket path %s, debug level %d%s%s", + socket_path, debug_level, be_quiet ? ", quiet" : "", + login_shell ? ", login shell" : ""); if (uname(&un) == 0) { ctx->print(ctx, "system is %s %s %s %s", un.sysname, un.release, un.version, un.machine); diff --git a/tmux.1 b/tmux.1 index e4d34e23..31c4897c 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.163 2009-09-03 20:44:38 tcunha Exp $ +.\" $Id: tmux.1,v 1.164 2009-09-03 21:02:55 tcunha Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -23,7 +23,7 @@ .Sh SYNOPSIS .Nm tmux .Bk -words -.Op Fl 28dqUuv +.Op Fl 28dlqUuv .Op Fl f Ar file .Op Fl L Ar socket-name .Op Fl S Ar socket-path @@ -120,6 +120,10 @@ commands which are executed in sequence when the server is first started. If a command in the configuration file fails, .Nm will report an error and exit without executing further commands. +.It Fl l +Behave as a login shell. +This flag currently has no effect and is for compatibility with other shells +when using tmux as a login shell. .It Fl L Ar socket-name .Nm stores the server socket in a directory under diff --git a/tmux.c b/tmux.c index 9460ad8e..c6ad8cfe 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.169 2009-09-03 20:44:38 tcunha Exp $ */ +/* $Id: tmux.c,v 1.170 2009-09-03 21:02:55 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -62,6 +62,7 @@ int debug_level; int be_quiet; time_t start_time; char *socket_path; +int login_shell; __dead void usage(void); char *makesockpath(const char *); @@ -77,8 +78,8 @@ __dead void usage(void) { fprintf(stderr, - "usage: %s [-28dqUuv] [-f file] [-L socket-name] [-S socket-path]\n" - " [command [flags]]\n", + "usage: %s [-28dlqUuv] [-f file] [-L socket-name]\n" + " [-S socket-path] [command [flags]]\n", __progname); exit(1); } @@ -325,8 +326,9 @@ main(int argc, char **argv) unlock = flags = 0; label = path = NULL; - while ((opt = getopt(argc, argv, "28df:L:qS:uUv")) != -1) { - switch (opt) { + login_shell = (**argv == '-'); + while ((opt = getopt(argc, argv, "28df:lL:qS:uUv")) != -1) { + switch (opt) { case '2': flags |= IDENTIFY_256COLOURS; flags &= ~IDENTIFY_88COLOURS; @@ -343,6 +345,9 @@ main(int argc, char **argv) xfree(cfg_file); cfg_file = xstrdup(optarg); break; + case 'l': + login_shell = 1; + break; case 'L': if (label != NULL) xfree(label); diff --git a/tmux.h b/tmux.h index 3bde8ee1..d6c58488 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.435 2009-09-03 20:44:38 tcunha Exp $ */ +/* $Id: tmux.h,v 1.436 2009-09-03 21:02:55 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1115,6 +1115,7 @@ extern int debug_level; extern int be_quiet; extern time_t start_time; extern char *socket_path; +extern int login_shell; void logfile(const char *); void siginit(void); void sigreset(void);