lib.ec.ssh: Don't quote shell operators

Naively join()ing a command list to be executed remotely via SSH also
quotes shell operators which doesn't work, of course. Work around
that. The workaround will not always work but covers lots of cases.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-10 14:58:29 +02:00
commit 84375cd482
4 changed files with 50 additions and 7 deletions

View file

@ -6,6 +6,8 @@ from ...log import *
from ...ExecContext import Result
from ..SSHClient import SSHClient as Base
from .util import join_cmd
_USE_DEFAULT_KNOWN_HOSTS = object()
class AsyncSSH(Base):
@ -52,7 +54,7 @@ class AsyncSSH(Base):
if not cmd:
raise ValueError("cmd must not be empty")
inner = f"exec {shlex.join(cmd)}"
inner = f"exec {join_cmd(cmd)}"
if wd is not None:
inner = f"cd {shlex.quote(wd)} && {inner}"