summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm <djm>2005-08-12 12:16:22 +0000
committerdjm <djm>2005-08-12 12:16:22 +0000
commitd8bcc7309d7352cc9e9e21ce14fda60979b31c19 (patch)
treedc7733697c6150ee202d3405e45edfdea15777d6
parentbae5d492275f1d4db43d210a687682cc6e6a1299 (diff)
downloadopenssh-d8bcc7309d7352cc9e9e21ce14fda60979b31c19.tar.gz
- jaredy@cvs.openbsd.org 2005/08/08 13:22:48
[sftp.c] sftp prompt enhancements: - in non-interactive mode, do not print an empty prompt at the end before finishing - print newline after EOF in editline mode - call el_end() in editline mode ok dtucker djm
-rw-r--r--ChangeLog10
-rw-r--r--sftp.c28
2 files changed, 29 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index d8d7bde6..ee165a21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,14 @@
[servconf.c]
Unbreak sshd ListenAddress for bare IPv6 addresses.
Report from Janusz Mucka; ok djm@
+ - jaredy@cvs.openbsd.org 2005/08/08 13:22:48
+ [sftp.c]
+ sftp prompt enhancements:
+ - in non-interactive mode, do not print an empty prompt at the end
+ before finishing
+ - print newline after EOF in editline mode
+ - call el_end() in editline mode
+ ok dtucker djm
20050810
- (dtucker) [configure.ac] Test libedit library and headers for compatibility.
@@ -2924,4 +2932,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
-$Id: ChangeLog,v 1.3870 2005/08/12 12:11:58 djm Exp $
+$Id: ChangeLog,v 1.3871 2005/08/12 12:16:22 djm Exp $
diff --git a/sftp.c b/sftp.c
index 9d236074..0f1aa4b5 100644
--- a/sftp.c
+++ b/sftp.c
@@ -16,7 +16,7 @@
#include "includes.h"
-RCSID("$OpenBSD: sftp.c,v 1.65 2005/07/17 07:17:55 djm Exp $");
+RCSID("$OpenBSD: sftp.c,v 1.66 2005/08/08 13:22:48 jaredy Exp $");
#ifdef USE_LIBEDIT
#include <histedit.h>
@@ -1237,7 +1237,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
char *dir = NULL;
char cmd[2048];
struct sftp_conn *conn;
- int err;
+ int err, interactive;
EditLine *el = NULL;
#ifdef USE_LIBEDIT
History *hl = NULL;
@@ -1303,6 +1303,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
setlinebuf(infile);
#endif
+ interactive = !batchmode && isatty(STDIN_FILENO);
err = 0;
for (;;) {
char *cp;
@@ -1310,20 +1311,28 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
signal(SIGINT, SIG_IGN);
if (el == NULL) {
- printf("sftp> ");
+ if (interactive)
+ printf("sftp> ");
if (fgets(cmd, sizeof(cmd), infile) == NULL) {
- printf("\n");
+ if (interactive)
+ printf("\n");
break;
}
- if (batchmode) /* Echo command */
- printf("%s", cmd);
+ if (!interactive) { /* Echo command */
+ printf("sftp> %s", cmd);
+ if (strlen(cmd) > 0 &&
+ cmd[strlen(cmd) - 1] != '\n')
+ printf("\n");
+ }
} else {
#ifdef USE_LIBEDIT
const char *line;
int count = 0;
- if ((line = el_gets(el, &count)) == NULL || count <= 0)
- break;
+ if ((line = el_gets(el, &count)) == NULL || count <= 0) {
+ printf("\n");
+ break;
+ }
history(hl, &hev, H_ENTER, line);
if (strlcpy(cmd, line, sizeof(cmd)) >= sizeof(cmd)) {
fprintf(stderr, "Error: input line too long\n");
@@ -1346,6 +1355,9 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
}
xfree(pwd);
+ if (el != NULL)
+ el_end(el);
+
/* err == 1 signifies normal "quit" exit */
return (err >= 0 ? 0 : -1);
}