From a9b364638dedd5c695923d9abe3494d910100308 Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 14 Sep 2022 15:26:33 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=AF=B9sh=E7=9A=84=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/libs/ssh.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spug_api/libs/ssh.py b/spug_api/libs/ssh.py index ac967b5..7f4d600 100644 --- a/spug_api/libs/ssh.py +++ b/spug_api/libs/ssh.py @@ -180,7 +180,8 @@ class SSH: counter = 0 self.channel = self.client.invoke_shell(**self.term) - command = 'set +o zle\n[ -n "$BASH_VERSION" ] && set +o history\n[ -n "$ZSH_VERSION" ] && set -o no_nomatch\n' + command = '[ -n "$BASH_VERSION" ] && set +o history\n' + command += '[ -n "$ZSH_VERSION" ] && set +o zle && set -o no_nomatch\n' command += 'export PS1= && stty -echo\n' command = self._handle_command(command, self.default_env) self.channel.sendall(command) @@ -221,7 +222,7 @@ class SSH: def _handle_command(self, command, environment): new_command = commands = '' if not self.exec_file: - self.exec_file = f'/tmp/{uuid4().hex}' + self.exec_file = f'/tmp/spug.{uuid4().hex}' commands += f'trap \'rm -f {self.exec_file}\' EXIT\n' env_command = self._make_env_command(environment) @@ -230,7 +231,7 @@ class SSH: new_command += command new_command += f'\necho {self.eof} $?\n' self.put_file_by_fl(StringIO(new_command), self.exec_file) - commands += f'source {self.exec_file}\n' + commands += f'. {self.exec_file}\n' return commands def _decode(self, content):