mirror of
https://github.com/xxh/xxh
synced 2025-02-16 20:38:27 +00:00
Quote SSH arguments
This commit is contained in:
parent
14379534ed
commit
965bb9c67a
2 changed files with 15 additions and 8 deletions
|
@ -14,9 +14,16 @@ def SC(cmd):
|
|||
[out, err] = proc.communicate()
|
||||
return (out, err, proc)
|
||||
|
||||
def A(args, q=0):
|
||||
def A(args, q=0, i=0):
|
||||
if type(args) == list:
|
||||
args = ' '.join([str(a) for a in args])
|
||||
if i == 1:
|
||||
args = ' '.join([f"'{a}'" for a in args])
|
||||
elif i == 2:
|
||||
args = ' '.join([f'"{a}"' for a in args])
|
||||
elif i == 3:
|
||||
args = ' '.join([f'\\"{a}\\"' for a in args])
|
||||
else:
|
||||
args = ' '.join([str(a) for a in args])
|
||||
if q == 1:
|
||||
return f"'{args}'"
|
||||
elif q == 2:
|
||||
|
|
|
@ -284,7 +284,7 @@ class xxh:
|
|||
host_info_s=host_info_s.strip().replace('\n','\\n').replace('"','\\"').replace('$','\\$').replace('`','\\`'),
|
||||
ssh=self.ssh_command,
|
||||
ssh_v=('' if not self.ssh_arg_v else '-v'),
|
||||
ssh_arguments=A(self.ssh_arguments),
|
||||
ssh_arguments=A(self.ssh_arguments, 0, 2),
|
||||
host=host
|
||||
)
|
||||
|
||||
|
@ -318,7 +318,7 @@ class xxh:
|
|||
sshpass=A(self.sshpass),
|
||||
ssh=A(self.ssh_command),
|
||||
ssh_arg_v=A(self.ssh_arg_v),
|
||||
ssh_arguments=A(self.ssh_arguments),
|
||||
ssh_arguments=A(self.ssh_arguments, 0, 2),
|
||||
host=A(host)
|
||||
))
|
||||
r = o.strip()
|
||||
|
@ -809,7 +809,7 @@ class xxh:
|
|||
sshpass=A(self.sshpass),
|
||||
ssh=A(self.ssh_command),
|
||||
ssh_arg_v=A(self.ssh_arg_v),
|
||||
ssh_arguments=A(self.ssh_arguments),
|
||||
ssh_arguments=A(self.ssh_arguments, 0, 2),
|
||||
host=A(host)
|
||||
)
|
||||
|
||||
|
@ -951,7 +951,7 @@ class xxh:
|
|||
sshpass=A(self.sshpass),
|
||||
ssh=A(self.ssh_command),
|
||||
ssh_arg_v=('' if self.ssh_arg_v == [] else '-v'),
|
||||
ssh_arguments=A(self.ssh_arguments),
|
||||
ssh_arguments=A(self.ssh_arguments, 0, 3),
|
||||
arg_q=A(arg_q),
|
||||
progress=('' if self.quiet or not self.verbose else '--progress')
|
||||
)
|
||||
|
@ -982,7 +982,7 @@ class xxh:
|
|||
sshpass=A(self.sshpass),
|
||||
scp_command=A(self.scp_command),
|
||||
ssh_arg_v=A(self.ssh_arg_v),
|
||||
ssh_arguments=A(self.ssh_arguments),
|
||||
ssh_arguments=A(self.ssh_arguments, 0, 1),
|
||||
arg_q=A(arg_q)
|
||||
)
|
||||
|
||||
|
@ -1079,7 +1079,7 @@ class xxh:
|
|||
sshpass=A(self.sshpass),
|
||||
ssh=A(self.ssh_command),
|
||||
ssh_arg_v=A(self.ssh_arg_v),
|
||||
ssh_arguments=A(self.ssh_arguments),
|
||||
ssh_arguments=A(self.ssh_arguments, 0, 1),
|
||||
host=A(host),
|
||||
entrypoint_command=entrypoint_command
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue