|
|
|
|
|
by theamk
372 days ago
|
|
Note that at least in python, you can use "shlex.quote" instead - it's in stdlib and does not need any extra tools. >>> import subprocess
>>> import shlex
>>> subprocess.run(['ssh', 'host', shlex.join(['ls', '-la', 'a filename with spaces'])])
ls: cannot access 'a filename with spaces': No such file or directory
works nested, too >>> layer2 = ['ls', '-la', 'a filename with spaces']
>>> layer1 = ['ssh', 'host1', shlex.join(layer2)]
>>> layer0 = ['ssh', 'host0', shlex.join(layer1)]
>>> subprocess.run(layer0)
(I am not sure if Rust has equivalent, but if it does not, it's probably easy to implement.. Python version is only a few lines long) |
|