aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-11 21:28:11 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-11 21:28:11 +0000
commit4310282a4c52f1885ae2eb80b106c9c03564a0b8 (patch)
tree21099e70cdd49e4dc08084bbd758e64677728774 /window.c
parent4ec8ade11c23eec4b652cdd7ea47ddf346b7be93 (diff)
downloadrtmux-4310282a4c52f1885ae2eb80b106c9c03564a0b8.tar.gz
rtmux-4310282a4c52f1885ae2eb80b106c9c03564a0b8.tar.bz2
rtmux-4310282a4c52f1885ae2eb80b106c9c03564a0b8.zip
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.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/window.c b/window.c
index 3976d7cc..d24d789b 100644
--- a/window.c
+++ b/window.c
@@ -61,18 +61,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