- djm@cvs.openbsd.org 2004/01/13 09:25:05
[sftp-int.c sftp.1 sftp.c]
Tidy sftp batchmode handling, eliminate junk to stderr (bugzilla #754) and
enable use of "-b -" to accept batchfile from stdin; ok markus@
diff --git a/sftp-int.c b/sftp-int.c
index edb475b..a9423fe 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -25,7 +25,7 @@
/* XXX: recursive operations */
#include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.65 2003/11/21 11:57:03 djm Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.66 2004/01/13 09:25:05 djm Exp $");
#include "buffer.h"
#include "xmalloc.h"
@@ -41,6 +41,9 @@
/* File to read commands from */
extern FILE *infile;
+/* Are we in batchfile mode? */
+extern int batchmode;
+
/* Size of buffer used when copying files */
extern size_t copy_buffer_len;
@@ -1172,14 +1175,16 @@
if (fgets(cmd, sizeof(cmd), infile) == NULL) {
printf("\n");
break;
- } else if (infile != stdin) /* Bluff typing */
+ }
+
+ if (batchmode) /* Echo command */
printf("%s", cmd);
cp = strrchr(cmd, '\n');
if (cp)
*cp = '\0';
- err = parse_dispatch_command(conn, cmd, &pwd, infile != stdin);
+ err = parse_dispatch_command(conn, cmd, &pwd, batchmode);
if (err != 0)
break;
}