I've seen the questions and answers about needing to double-escape the arguments to remote ssh commands. My question is: Exactly where and when does the second parsing get done?
If I run the following:
$ ssh otherhost pstree -a -p
I see the following in the output:
|-sshd,3736 | `-sshd,1102 | `-sshd,1109 | `-pstree,1112 -a -p
The parent process for the remote command (
sshd, there doesn't appear to be any shell there that would be parsing the command line arguments to the remote command, so it doesn't seem as if double quoting or escaping would be necessary (but it definitely is). If instead I ssh there first and get a login shell, and then run
pstree -a -p I see the following in the output:
├─sshd,3736 │ └─sshd,3733 │ └─sshd,3735 │ └─bash,3737 │ └─pstree,4130 -a -p
So clearly there's a
bash shell there that would do command line parsing in that case. But the case where I use a remote command directly, there doesn't seem to be a shell, so why is double quoting necessary?