diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-10-20 09:57:08 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-10-20 09:57:08 +0000 |
commit | f2f1b8fc8180f205802f23e93c294c2cf65c117e (patch) | |
tree | 12dd11f3b93a6e68e82ce4150a69f4ce74d59555 /tmux.c | |
parent | 8d09be0cb1e4efad485cce299579d04a0db9d222 (diff) | |
download | rtmux-f2f1b8fc8180f205802f23e93c294c2cf65c117e.tar.gz rtmux-f2f1b8fc8180f205802f23e93c294c2cf65c117e.tar.bz2 rtmux-f2f1b8fc8180f205802f23e93c294c2cf65c117e.zip |
Add default-command option and change default to be $SHELL rather than $SHELL -l. Also try to read shell from passwd db if $SHELL isn't present.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.34 2007-10-19 21:58:17 nicm Exp $ */ +/* $Id: tmux.c,v 1.35 2007-10-20 09:57:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -23,6 +23,7 @@ #include <errno.h> #include <paths.h> #include <poll.h> +#include <pwd.h> #include <signal.h> #include <stdlib.h> #include <string.h> @@ -168,6 +169,7 @@ main(int argc, char **argv) struct pollfd pfd; struct hdr hdr; const char *shell; + struct passwd *pw; char *path, *cause, name[MAXNAMELEN]; int n, opt; @@ -203,9 +205,15 @@ main(int argc, char **argv) bell_action = BELL_ANY; shell = getenv("SHELL"); - if (shell == NULL || *shell == '\0') - shell = "/bin/ksh"; - xasprintf(&default_command, "exec %s -l", shell); + if (shell == NULL || *shell == '\0') { + pw = getpwuid(getuid()); + if (pw != NULL) + shell = pw->pw_shell; + endpwent(); + if (shell == NULL || *shell == '\0') + shell = _PATH_BSHELL; + } + xasprintf(&default_command, "exec %s", shell); if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) { if (cause == NULL) |