Refactor default shell handling so it is done in a single place for a new windows and a new tab.
Use "/bin/sh -l" as the default command, and always pass -l ('login shell') to the user selected shell.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38173 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -58,6 +59,7 @@
|
|||||||
#define CSWTCH 0
|
#define CSWTCH 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char *kDefaultShell = "/bin/sh";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set environment variable.
|
* Set environment variable.
|
||||||
@@ -335,10 +337,20 @@ initialize_termios(struct termios &tio)
|
|||||||
status_t
|
status_t
|
||||||
Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **argv)
|
Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
const char *kDefaultShellCommand[] = { "/bin/bash", "--login", NULL };
|
|
||||||
|
|
||||||
if (argv == NULL || argc == 0) {
|
if (argv == NULL || argc == 0) {
|
||||||
argv = kDefaultShellCommand;
|
const char *defaultArgs[2];
|
||||||
|
defaultArgs[0] = kDefaultShell;
|
||||||
|
defaultArgs[1] = "-l";
|
||||||
|
|
||||||
|
struct passwd passwdStruct;
|
||||||
|
struct passwd *passwdResult;
|
||||||
|
char stringBuffer[256];
|
||||||
|
if (!getpwuid_r(getuid(), &passwdStruct, stringBuffer,
|
||||||
|
sizeof(stringBuffer), &passwdResult)) {
|
||||||
|
defaultArgs[0] = passwdStruct.pw_shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
argv = defaultArgs;
|
||||||
argc = 2;
|
argc = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,8 +550,8 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
|
|||||||
|
|
||||||
int returnValue = system(alertCommand.String());
|
int returnValue = system(alertCommand.String());
|
||||||
if (returnValue == 0) {
|
if (returnValue == 0) {
|
||||||
execl(kDefaultShellCommand[0], kDefaultShellCommand[0],
|
execl(kDefaultShell, kDefaultShell,
|
||||||
kDefaultShellCommand[1], NULL);
|
"-l", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include "TermApp.h"
|
#include "TermApp.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pwd.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -39,7 +38,6 @@
|
|||||||
static bool sUsageRequested = false;
|
static bool sUsageRequested = false;
|
||||||
//static bool sGeometryRequested = false;
|
//static bool sGeometryRequested = false;
|
||||||
|
|
||||||
const char *kDefaultShell = "/bin/bash";
|
|
||||||
const ulong MSG_ACTIVATE_TERM = 'msat';
|
const ulong MSG_ACTIVATE_TERM = 'msat';
|
||||||
const ulong MSG_TERM_WINDOW_INFO = 'mtwi';
|
const ulong MSG_TERM_WINDOW_INFO = 'mtwi';
|
||||||
|
|
||||||
@@ -63,19 +61,8 @@ TermApp::TermApp()
|
|||||||
fTermWindow(NULL),
|
fTermWindow(NULL),
|
||||||
fArgs(NULL)
|
fArgs(NULL)
|
||||||
{
|
{
|
||||||
const char *defaultArgs[2];
|
|
||||||
defaultArgs[0] = kDefaultShell;
|
|
||||||
defaultArgs[1] = "--login";
|
|
||||||
|
|
||||||
struct passwd passwdStruct;
|
fArgs = new Arguments(0, NULL);
|
||||||
struct passwd *passwdResult;
|
|
||||||
char stringBuffer[256];
|
|
||||||
if (!getpwuid_r(getuid(), &passwdStruct, stringBuffer,
|
|
||||||
sizeof(stringBuffer), &passwdResult)) {
|
|
||||||
defaultArgs[0] = passwdStruct.pw_shell;
|
|
||||||
}
|
|
||||||
|
|
||||||
fArgs = new Arguments(2, defaultArgs);
|
|
||||||
|
|
||||||
fWindowTitle = B_TRANSLATE("Terminal");
|
fWindowTitle = B_TRANSLATE("Terminal");
|
||||||
_RegisterTerminal();
|
_RegisterTerminal();
|
||||||
|
|||||||
Reference in New Issue
Block a user