]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - psftp.c
Fiddly things involving pruning .svn directories, not mentioning
[PuTTY.git] / psftp.c
diff --git a/psftp.c b/psftp.c
index 079a61f33eef8178ec1f6710f1319e43272f5bd4..ba038b0751df866d5687a3d2c0efae7bbcdb5df9 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -1870,7 +1870,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
 
     /* See if host is of the form user@host */
     if (cfg.host[0] != '\0') {
-       char *atsign = strchr(cfg.host, '@');
+       char *atsign = strrchr(cfg.host, '@');
        /* Make sure we're not overflowing the user field */
        if (atsign) {
            if (atsign - cfg.host < sizeof cfg.username) {
@@ -2066,6 +2066,15 @@ int psftp_main(int argc, char *argv[])
     argv += i;
     back = NULL;
 
+    /*
+     * If the loaded session provides a hostname, and a hostname has not
+     * otherwise been specified, pop it in `userhost' so that
+     * `psftp -load sessname' is sufficient to start a session.
+     */
+    if (!userhost && cfg.host[0] != '\0') {
+       userhost = dupstr(cfg.host);
+    }
+
     /*
      * If a user@host string has already been provided, connect to
      * it now.