1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Merge branch 'pre-0.65'

This commit is contained in:
Ben Harris 2015-06-25 23:38:41 +01:00
commit 9e20c81bc9

18
psftp.c
View File

@ -2394,7 +2394,7 @@ void do_sftp_cleanup()
} }
} }
void do_sftp(int mode, int modeflags, char *batchfile) int do_sftp(int mode, int modeflags, char *batchfile)
{ {
FILE *fp; FILE *fp;
int ret; int ret;
@ -2427,8 +2427,9 @@ void do_sftp(int mode, int modeflags, char *batchfile)
fp = fopen(batchfile, "r"); fp = fopen(batchfile, "r");
if (!fp) { if (!fp) {
printf("Fatal: unable to open %s\n", batchfile); printf("Fatal: unable to open %s\n", batchfile);
return; return 1;
} }
ret = 0;
while (1) { while (1) {
struct sftp_command *cmd; struct sftp_command *cmd;
cmd = sftp_getcmd(fp, mode, modeflags); cmd = sftp_getcmd(fp, mode, modeflags);
@ -2443,8 +2444,13 @@ void do_sftp(int mode, int modeflags, char *batchfile)
} }
} }
fclose(fp); fclose(fp);
/*
* In batch mode, and if exit on command failure is enabled,
* any command failure causes the whole of PSFTP to fail.
*/
if (ret == 0 && !(modeflags & 2)) return 2;
} }
return 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -2891,7 +2897,7 @@ const int share_can_be_upstream = FALSE;
*/ */
int psftp_main(int argc, char *argv[]) int psftp_main(int argc, char *argv[])
{ {
int i; int i, ret;
int portnumber = 0; int portnumber = 0;
char *userhost, *user; char *userhost, *user;
int mode = 0; int mode = 0;
@ -2987,7 +2993,7 @@ int psftp_main(int argc, char *argv[])
" to connect\n"); " to connect\n");
} }
do_sftp(mode, modeflags, batchfile); ret = do_sftp(mode, modeflags, batchfile);
if (back != NULL && back->connected(backhandle)) { if (back != NULL && back->connected(backhandle)) {
char ch; char ch;
@ -3001,5 +3007,5 @@ int psftp_main(int argc, char *argv[])
console_provide_logctx(NULL); console_provide_logctx(NULL);
sk_cleanup(); sk_cleanup();
return 0; return ret;
} }