The first command of a nested compound command receives no arguments

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Hello,

The following three commands work as expected:

root@cosmic:~# ssh localhost 'echo 1 && echo 2 && echo 3'
1
2
3
root@cosmic:~# ssh localhost "dash -c 'echo 1 && echo 2 && echo 3'"
1
2
3
root@cosmic:~# ssh localhost echo 1 2 3 4 5
1 2 3 4 5

The following three commands produce unexpected behavior.
Specifically, it appears that the first nested command is called with
no arguments.

root@cosmic:~# ssh localhost dash -c 'echo 1 && echo 2 && echo 3'

2
3
root@cosmic:~# ssh localhost dash -c 'touch a && touch b && touch c'
touch: missing file operand
Try 'touch --help' for more information.
root@cosmic:~# ssh localhost dash -c 'touch a b && touch c d && touch e f'
touch: missing file operand
Try 'touch --help' for more information.

Is the above the intended behavior?  If so, why?  What is going on?
It seems strange to me.

The above commands were run on Ubuntu 18.10 on a VPS at Digital Ocean.
The openssh package version appears to be: 1:7.7p1-4.

Another pair of examples:

root@cosmic:~# ssh localhost dash -c 'hostname && hostname && hostname'
cosmic
cosmic
cosmic
root@cosmic:~# ssh localhost dash -c 'echo `hostname` && echo
`hostname` && echo `hostname`'

cosmic
cosmic

Another strange example:

root@cosmic:~# ssh localhost dash -c 'exit 2 && exit 3 && exit 4'
(Will exit with status of 3.)

Thank you,

Parke
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux