=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tmux.c,v retrieving revision 1.38 retrieving revision 1.39 diff -c -r1.38 -r1.39 *** src/usr.bin/tmux/tmux.c 2009/09/01 09:11:05 1.38 --- src/usr.bin/tmux/tmux.c 2009/09/01 13:09:50 1.39 *************** *** 1,4 **** ! /* $OpenBSD: tmux.c,v 1.38 2009/09/01 09:11:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tmux.c,v 1.39 2009/09/01 13:09:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 175,180 **** --- 175,224 ---- fatal("sigaction failed"); } + const char * + getshell(void) + { + struct passwd *pw; + const char *shell; + + shell = getenv("SHELL"); + if (checkshell(shell)) + return (shell); + + pw = getpwuid(getuid()); + if (pw != NULL && checkshell(pw->pw_shell)) + return (pw->pw_shell); + + return (_PATH_BSHELL); + } + + int + checkshell(const char *shell) + { + if (shell == NULL || *shell == '\0' || areshell(shell)) + return (0); + if (access(shell, X_OK) != 0) + return (0); + return (1); + } + + int + areshell(const char *shell) + { + const char *progname, *ptr; + + if ((ptr = strrchr(shell, '/')) != NULL) + ptr++; + else + ptr = shell; + progname = __progname; + if (*progname == '-') + progname++; + if (strcmp(ptr, progname) == 0) + return (1); + return (0); + } + char * makesockpath(const char *label) { *************** *** 346,351 **** --- 390,397 ---- options_set_number(&global_s_options, "bell-action", BELL_ANY); options_set_number(&global_s_options, "buffer-limit", 9); options_set_string(&global_s_options, "default-command", "%s", ""); + options_set_string( + &global_s_options, "default-shell", "%s", getshell()); options_set_string(&global_s_options, "default-terminal", "screen"); options_set_number(&global_s_options, "display-panes-colour", 4); options_set_number(&global_s_options, "display-panes-time", 1000);