1919use Symfony \Component \Process \Process ;
2020
2121use function Deployer \quote ;
22+ use function Deployer \Support \rsync_rsh ;
2223use function Deployer \writeln ;
2324
2425class Rsync
@@ -58,9 +59,10 @@ public function call(Host $host, $source, string $destination, array $config = [
5859 $ options [] = '--stats ' ;
5960 }
6061
61- $ connectionOptions = $ host ->connectionOptionsString ();
62- if ($ connectionOptions !== '' ) {
63- $ options = array_merge ($ options , ['-e ' , "ssh $ connectionOptions " ]);
62+ $ connectionOptions = $ host ->connectionOptions ();
63+ if (!empty ($ connectionOptions )) {
64+ $ rsh = rsync_rsh ($ connectionOptions );
65+ $ options = array_merge ($ options , ['-e ' , $ rsh ]);
6466 }
6567 if ($ host ->has ('become ' ) && !empty ($ host ->get ('become ' ))) {
6668 $ options = array_merge ($ options , ['--rsync-path ' , "sudo -H -u {$ host ->get ('become ' )} rsync " ]);
@@ -75,12 +77,12 @@ function (string $value) {
7577 },
7678 ));
7779
78- $ commandString = $ command [0 ];
80+ $ printCommandForDebug = $ command [0 ];
7981 for ($ i = 1 ; $ i < count ($ command ); $ i ++) {
80- $ commandString .= ' ' . quote ($ command [$ i ]);
82+ $ printCommandForDebug .= ' ' . quote ($ command [$ i ]);
8183 }
8284 if ($ this ->output ->isVerbose ()) {
83- $ this ->output ->writeln ("[ $ host] $ commandString " );
85+ $ this ->output ->writeln ("[ $ host] $ printCommandForDebug " );
8486 }
8587
8688 $ progressBar = null ;
@@ -138,7 +140,7 @@ function (string $value) {
138140 } catch (ProcessFailedException $ exception ) {
139141 throw new RunException (
140142 $ host ,
141- $ commandString ,
143+ $ printCommandForDebug ,
142144 $ process ->getExitCode (),
143145 $ process ->getOutput (),
144146 $ process ->getErrorOutput (),
0 commit comments