aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-08-14 21:23:20 +0000
committerTiago Cunha <tcunha@gmx.com>2009-08-14 21:23:20 +0000
commite2a18894b34e3651feecba1dd43c4f05c9566509 (patch)
treea15c5d4ff41e637982452222ede90d433dbc10a6 /window.c
parent0714e411488e01273729bc0801e197a8f64d5540 (diff)
downloadrtmux-e2a18894b34e3651feecba1dd43c4f05c9566509.tar.gz
rtmux-e2a18894b34e3651feecba1dd43c4f05c9566509.tar.bz2
rtmux-e2a18894b34e3651feecba1dd43c4f05c9566509.zip
Sync OpenBSD patchset 246:
Have the client pass its stdin fd to the server when identifying itself and have the server use that rather than reopening the tty. If the fd isn't given, use the old behaviour (so no need for a version change). This allows tmux to be used as the shell, so also change so that when working out the command to execute if default-command is empty (the default), tmux will try not execute itself.
Diffstat (limited to 'window.c')
-rw-r--r--window.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/window.c b/window.c
index 60cc4d54..3d680149 100644
--- a/window.c
+++ b/window.c
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.100 2009-08-09 17:48:55 tcunha Exp $ */
+/* $Id: window.c,v 1.101 2009-08-14 21:23:20 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -59,18 +59,29 @@ RB_GENERATE(winlinks, winlink, entry, winlink_cmp);
const char *
window_default_command(void)
{
- const char *shell;
+ const char *shell, *ptr;
struct passwd *pw;
shell = getenv("SHELL");
if (shell != NULL && *shell != '\0')
- return (shell);
+ goto found;
pw = getpwuid(getuid());
- if (pw != NULL && pw->pw_shell != NULL && *pw->pw_shell != '\0')
- return (pw->pw_shell);
+ if (pw != NULL && pw->pw_shell != NULL && *pw->pw_shell != '\0') {
+ shell = pw->pw_shell;
+ goto found;
+ }
return (_PATH_BSHELL);
+
+found:
+ if ((ptr = strrchr(shell, '/')) != NULL)
+ ptr++;
+ else
+ ptr = shell;
+ if (strcmp(ptr, __progname) == 0)
+ return (_PATH_BSHELL);
+ return (shell);
}
int