- 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
This commit is contained in:
parent
8e489484a1
commit
0e2c102858
10
ChangeLog
10
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 $
|
||||
|
|
28
sftp.c
28
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue