The first command of a nested compound command receives no arguments

Parke at
Mon Oct 22 04:21:56 AEDT 2018


Thanks to Timo and Christian for their answers.

On Sun, Oct 21, 2018 at 3:32 AM Timo Kilpilehto <timo at> wrote:
> eval sh -c "echo none of this makes any difference"

Where is it documented that ssh is going to eval my command?  The fact
remains that ssh does not transparently pass the command to the remote

This pair of commands result in the same output (a blank line):

$ dash -c echo 1
$ ssh localhost dash -c echo 1

However, the following three pairs of commands result in different output:

$ dash -c 'echo 1'
$ ssh localhost dash -c 'echo 1'

$ dash -c echo\ 1
$ ssh localhost dash -c echo\ 1

$ dash -c 'echo\ 1'
$ ssh localhost dash -c 'echo\ 1'

It appears that what is happening is that ssh is flattening the
multiple command arguments to a single string without escaping them.
(I concede there may be no "standard" way to do such escaping.)

It also appears that the ssh protocol defines the command as a single
string, not an argv-style list of multiple strings.  (See section 6.5
of .)

It might be worth documenting the escape-less flattening of the
command (and the corresponding loss of information) on the ssh
manpage.  I could write something and submit a patch, if the openssh
developers are interested.



More information about the openssh-unix-dev mailing list