merging trunk rev 262
This commit is contained in:
commit
101dcf5d03
44
terminator
44
terminator
|
@ -153,7 +153,9 @@ class TerminatorTerm:
|
|||
if not env_proxy:
|
||||
os.putenv ('http_proxy', self.conf.http_proxy)
|
||||
|
||||
self.spawn_child ()
|
||||
if self.spawn_child () == -1:
|
||||
# We failed to usefully create a child shell, we need to kill ourself
|
||||
gobject.timeout_add (100, self.terminator.closeterm, self)
|
||||
|
||||
def add_matches (self, lboundry="[[:<:]]", rboundry="[[:>:]]"):
|
||||
userchars = "-A-Za-z0-9"
|
||||
|
@ -178,6 +180,8 @@ class TerminatorTerm:
|
|||
def spawn_child (self, event=None):
|
||||
update_records = self.conf.update_records
|
||||
login = self.conf.login_shell
|
||||
args = []
|
||||
shell = ''
|
||||
|
||||
if self.command:
|
||||
args = self.command
|
||||
|
@ -185,24 +189,50 @@ class TerminatorTerm:
|
|||
elif self.conf.use_custom_command:
|
||||
args = self.conf.custom_command.split ()
|
||||
shell = args[0]
|
||||
|
||||
if not os.path.exists (shell):
|
||||
shell = os.getenv ('SHELL') or ''
|
||||
if not os.path.exists (shell):
|
||||
shell = pwd.getpwuid (os.getuid ())[6] or ''
|
||||
if not os.path.exists (shell):
|
||||
for i in ['bash','zsh','tcsh','ksh','csh','sh']:
|
||||
shell = '/usr/bin/%s'%i
|
||||
if not os.path.exists (shell):
|
||||
shell = '/bin/%s'%i
|
||||
if not os.path.exists (shell):
|
||||
continue
|
||||
else:
|
||||
shell = pwd.getpwuid (os.getuid ())[6]
|
||||
args = [os.path.basename (shell)]
|
||||
break
|
||||
else:
|
||||
break;
|
||||
|
||||
if not os.path.exists (shell):
|
||||
# Give up, we're completely stuck
|
||||
print >> sys.stderr, _('Unable to find a shell')
|
||||
return (-1)
|
||||
|
||||
if not args:
|
||||
args.append (shell)
|
||||
|
||||
self._pid = self._vte.fork_command (command = shell, argv = args, envv = [], directory=self.cwd, loglastlog = login, logwtmp = update_records, logutmp = update_records)
|
||||
|
||||
if self._pid == -1:
|
||||
print >>sys.stderr, _('Unable to start shell: ') + shell
|
||||
return (-1)
|
||||
|
||||
def get_cwd (self):
|
||||
""" Return the current working directory of the subprocess.
|
||||
This function requires OS specific behaviours
|
||||
"""
|
||||
cwd = None
|
||||
system = platform.system ()
|
||||
|
||||
if system == 'Linux':
|
||||
try:
|
||||
cwd = os.path.realpath ('/proc/%s/cwd' % self._pid)
|
||||
else:
|
||||
# We don't have a child cwd getter for this platform, so let
|
||||
# TerminatorTerm use its default
|
||||
cwd = None
|
||||
except:
|
||||
pass
|
||||
|
||||
return (cwd)
|
||||
|
||||
def reconfigure_vte (self):
|
||||
|
|
Loading…
Reference in New Issue