Skip to content

Commit

Permalink
Changed tar command used to copy a remote command (fixes xebialabs#116).
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Partington committed May 6, 2014
1 parent a8c2ca7 commit a756fc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class ConnectionOptions {
/**
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForUnix">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_UNIX_DEFAULT = "tar c -C {0} . | tar xm -C {1}";
public static final String DIRECTORY_COPY_COMMAND_FOR_UNIX_DEFAULT = "cd {1} ; tar -cf - -C {0} . | tar xpf -";

/**
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForWindows">the online documentation</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,21 @@ protected CmdLine processCommandLine(final CmdLine cmd) {
@VisibleForTesting
CmdLine prefixWithElevationCommand(final CmdLine commandLine) {
CmdLine commandLineWithSudo = new CmdLine();
commandLineWithSudo.addTemplatedFragment(elevationCommandPrefix, elevatedUsername);
if (quoteCommand) {
commandLineWithSudo.addTemplatedFragment(elevationCommandPrefix, elevatedUsername);
commandLineWithSudo.addNested(commandLine);
} else {
boolean shouldAddElevationCommand = true;
for (CmdLineArgument a : commandLine.getArguments()) {
if(shouldAddElevationCommand && !a.toString(os, false).equals("cd")) {
commandLineWithSudo.addTemplatedFragment(elevationCommandPrefix, elevatedUsername);
}
shouldAddElevationCommand = false;

commandLineWithSudo.add(a);

if (a.toString(os, false).equals("|") || a.toString(os, false).equals(";")) {
commandLineWithSudo.addTemplatedFragment(elevationCommandPrefix, elevatedUsername);
shouldAddElevationCommand = true;
}
}
}
Expand Down

0 comments on commit a756fc9

Please sign in to comment.