[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.
#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>
char *dir = NULL;
char cmd[2048];
struct sftp_conn *conn;
- int err;
+ int err, interactive;
EditLine *el = NULL;
#ifdef USE_LIBEDIT
History *hl = NULL;
setlinebuf(infile);
#endif
+ interactive = !batchmode && isatty(STDIN_FILENO);
err = 0;
for (;;) {
char *cp;
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");
}
xfree(pwd);
+ if (el != NULL)
+ el_end(el);
+
/* err == 1 signifies normal "quit" exit */
return (err >= 0 ? 0 : -1);
}