=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/sftp-int.c,v retrieving revision 1.22.2.3 retrieving revision 1.22.2.4 diff -u -r1.22.2.3 -r1.22.2.4 --- src/usr.bin/ssh/Attic/sftp-int.c 2001/03/21 19:46:29 1.22.2.3 +++ src/usr.bin/ssh/Attic/sftp-int.c 2001/05/07 21:09:34 1.22.2.4 @@ -26,7 +26,7 @@ /* XXX: recursive operations */ #include "includes.h" -RCSID("$OpenBSD: sftp-int.c,v 1.22.2.3 2001/03/21 19:46:29 jason Exp $"); +RCSID("$OpenBSD: sftp-int.c,v 1.22.2.4 2001/05/07 21:09:34 jason Exp $"); #include @@ -88,6 +88,7 @@ { "dir", I_LS }, { "exit", I_QUIT }, { "get", I_GET }, + { "mget", I_GET }, { "help", I_HELP }, { "lcd", I_LCHDIR }, { "lchdir", I_LCHDIR }, @@ -99,6 +100,7 @@ { "lumask", I_LUMASK }, { "mkdir", I_MKDIR }, { "put", I_PUT }, + { "mput", I_PUT }, { "pwd", I_PWD }, { "quit", I_QUIT }, { "rename", I_RENAME }, @@ -146,7 +148,7 @@ void local_do_shell(const char *args) { - int ret, status; + int status; char *shell; pid_t pid; @@ -163,10 +165,10 @@ /* XXX: child has pipe fds to ssh subproc open - issue? */ if (args) { debug3("Executing %s -c \"%s\"", shell, args); - ret = execl(shell, shell, "-c", args, NULL); + execl(shell, shell, "-c", args, NULL); } else { debug3("Executing %s", shell); - ret = execl(shell, shell, NULL); + execl(shell, shell, NULL); } fprintf(stderr, "Couldn't execute \"%s\": %s\n", shell, strerror(errno)); @@ -453,9 +455,12 @@ xfree(tmp); } else abs_dst = xstrdup(tmp_dst); - } else if (infer_path(g.gl_pathv[0], &abs_dst)) { - err = -1; - goto out; + } else { + if (infer_path(g.gl_pathv[0], &abs_dst)) { + err = -1; + goto out; + } + abs_dst = make_absolute(abs_dst, pwd); } printf("Uploading %s to %s\n", g.gl_pathv[0], abs_dst); err = do_upload(in, out, g.gl_pathv[0], abs_dst, pflag); @@ -664,8 +669,8 @@ break; case I_PUT: err = process_put(in, out, path1, path2, *pwd, pflag); - break; - case I_RENAME: + break; + case I_RENAME: path1 = make_absolute(path1, *pwd); path2 = make_absolute(path2, *pwd); err = do_rename(in, out, path1, path2); @@ -853,9 +858,10 @@ } void -interactive_loop(int fd_in, int fd_out) +interactive_loop(int fd_in, int fd_out, char *file1, char *file2) { char *pwd; + char *dir = NULL; char cmd[2048]; version = do_init(fd_in, fd_out); @@ -866,6 +872,25 @@ if (pwd == NULL) fatal("Need cwd"); + if (file1 != NULL) { + dir = xstrdup(file1); + dir = make_absolute(dir, pwd); + + if (remote_is_dir(fd_in, fd_out, dir) && file2 == NULL) { + printf("Changing to: %s\n", dir); + snprintf(cmd, sizeof cmd, "cd \"%s\"", dir); + parse_dispatch_command(fd_in, fd_out, cmd, &pwd); + } else { + if (file2 == NULL) + snprintf(cmd, sizeof cmd, "get %s", dir); + else + snprintf(cmd, sizeof cmd, "get %s %s", dir, + file2); + + parse_dispatch_command(fd_in, fd_out, cmd, &pwd); + return; + } + } setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(infile, NULL, _IOLBF, 0);