Skip to content

Commit

Permalink
Fix #4232.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Aug 11, 2010
1 parent 28837d8 commit 4681206
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions source/ch/cyberduck/core/Preferences.java
Expand Up @@ -686,6 +686,7 @@ protected void setDefaults() {

defaults.put("terminal.bundle.identifier", "com.apple.Terminal");
defaults.put("terminal.command", "do script \"{0}\"");
defaults.put("terminal.command.ssh", "ssh -t {0} {1}@{2} -p {3} \"cd {4} && exec \\$SHELL\"");
}

/**
Expand Down
28 changes: 14 additions & 14 deletions source/ch/cyberduck/ui/cocoa/BrowserController.java
Expand Up @@ -63,8 +63,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.sun.jna.ptr.PointerByReference;

import java.io.File;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
Expand Down Expand Up @@ -2998,26 +2996,28 @@ public void openTerminalButtonClicked(final ID sender) {
log.error("Application with bundle identifier " + Preferences.instance().getProperty("terminal.bundle.identifier") + " is not installed");
return;
}
String ssh = "ssh -t "
+ (identity ? "-i " + this.getSession().getHost().getCredentials().getIdentity().getAbsolute() : "")
+ " "
+ this.getSession().getHost().getCredentials().getUsername()
+ "@"
+ this.getSession().getHost().getHostname()
+ " "
+ "-p " + this.getSession().getHost().getPort()
+ " "
+ "\\\"cd " + workdir + " && exec \\\\$SHELL\\\"";
final String command
String ssh = MessageFormat.format(Preferences.instance().getProperty("terminal.command.ssh"),
identity ? "-i " + this.getSession().getHost().getCredentials().getIdentity().getAbsolute() : "",
this.getSession().getHost().getCredentials().getUsername(),
this.getSession().getHost().getHostname(),
this.getSession().getHost().getPort(), workdir);
log.info("SSH Command:" + ssh);
// Escape
ssh = StringUtils.replace(ssh, "\\", "\\\\");
// Escape all " for do script command
ssh = StringUtils.replace(ssh, "\"", "\\\"");
log.info("Escaped SSH Command for Applescript:" + ssh);
String command
= "tell application \"" + LocalFactory.createLocal(app).getDisplayName() + "\""
+ "\n"
+ "activate"
+ "\n"
+ MessageFormat.format(Preferences.instance().getProperty("terminal.command"), ssh)
+ "\n"
+ "end tell";
log.info("Excecuting AppleScript:" + command);
final NSAppleScript as = NSAppleScript.createWithSource(command);
as.executeAndReturnError(new PointerByReference());
as.executeAndReturnError(null);
}

@Action
Expand Down

0 comments on commit 4681206

Please sign in to comment.