[Bug 2563] ssh bash -c drops arguments of the first command send to the remote.
bugzilla-daemon at bugzilla.mindrot.org
bugzilla-daemon at bugzilla.mindrot.org
Fri Apr 8 22:07:43 AEST 2016
https://bugzilla.mindrot.org/show_bug.cgi?id=2563
--- Comment #3 from Pascal Bourguignon <pjb at informatimago.com> ---
I've identified the reason of the observed behavior: bash -c takes a
single command (as documented), but if it is followed by arguments,
then they are used as "command line arguments", assigned to $0 $1 ...
For example:
$ bash -c 'echo $0 $@' foo \; echo bar
foo ; echo bar
$
so:
ssh ... bash -c 'echo foo;echo bar'
sends and executes remotely:
bash -c echo foo ; echo bar
with:
bash -c echo foo
assigning foo to $0 (no other command line argument), bash executing
therefore just 'echo'.
Then something strange occurs, since it seems that the following
; echo bar
gets evaluated somehow (probably by a shell forked by ssh on the remote
side).
The whole situation is messy, and I definitely think that ssh should
either concatenate the arguments to make a single command to be
executed remotely, or it should signal an error when it's given
additionnal arguments, instead of forwarding them to the remote side to
be processed in ways that are not very strictly controlled, documented
or well known.
--
You are receiving this mail because:
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list