improve zsh compatibility

pull/410/head
vapao 2021-09-20 01:07:56 +08:00
parent 4dc4123d14
commit c67f7c2207
1 changed files with 3 additions and 3 deletions

View File

@ -18,7 +18,7 @@ class SSH:
self.sftp = None self.sftp = None
self.eof = 'Spug EOF 2108111926' self.eof = 'Spug EOF 2108111926'
self.default_env = self._make_env_command(default_env) self.default_env = self._make_env_command(default_env)
self.regex = re.compile(r'Spug EOF 2108111926 -?\d+[\r\n]?$') self.regex = re.compile(r'Spug EOF 2108111926 (-?\d+)[\r\n]?')
self.arguments = { self.arguments = {
'hostname': hostname, 'hostname': hostname,
'port': port, 'port': port,
@ -104,7 +104,7 @@ class SSH:
break break
match = self.regex.search(line) match = self.regex.search(line)
if match: if match:
exit_code = int(line.rsplit()[-1]) exit_code = int(match.group(1))
line = line[:match.start()] line = line[:match.start()]
break break
yield exit_code, line yield exit_code, line
@ -132,7 +132,7 @@ class SSH:
counter = 0 counter = 0
self.channel = self.client.invoke_shell() self.channel = self.client.invoke_shell()
command = 'export PS1= && stty -echo\n' command = 'export PS1= && stty -echo; unsetopt zle\n'
if self.default_env: if self.default_env:
command += f'{self.default_env}\n' command += f'{self.default_env}\n'
command += f'echo {self.eof} $?\n' command += f'echo {self.eof} $?\n'