diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | sftp.c | 28 |
2 files changed, 29 insertions, 9 deletions
@@ -14,6 +14,14 @@ | |||
14 | [servconf.c] | 14 | [servconf.c] |
15 | Unbreak sshd ListenAddress for bare IPv6 addresses. | 15 | Unbreak sshd ListenAddress for bare IPv6 addresses. |
16 | Report from Janusz Mucka; ok djm@ | 16 | Report from Janusz Mucka; ok djm@ |
17 | - jaredy@cvs.openbsd.org 2005/08/08 13:22:48 | ||
18 | [sftp.c] | ||
19 | sftp prompt enhancements: | ||
20 | - in non-interactive mode, do not print an empty prompt at the end | ||
21 | before finishing | ||
22 | - print newline after EOF in editline mode | ||
23 | - call el_end() in editline mode | ||
24 | ok dtucker djm | ||
17 | 25 | ||
18 | 20050810 | 26 | 20050810 |
19 | - (dtucker) [configure.ac] Test libedit library and headers for compatibility. | 27 | - (dtucker) [configure.ac] Test libedit library and headers for compatibility. |
@@ -2924,4 +2932,4 @@ | |||
2924 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 2932 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
2925 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 2933 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
2926 | 2934 | ||
2927 | $Id: ChangeLog,v 1.3870 2005/08/12 12:11:58 djm Exp $ | 2935 | $Id: ChangeLog,v 1.3871 2005/08/12 12:16:22 djm Exp $ |
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | #include "includes.h" | 17 | #include "includes.h" |
18 | 18 | ||
19 | RCSID("$OpenBSD: sftp.c,v 1.65 2005/07/17 07:17:55 djm Exp $"); | 19 | RCSID("$OpenBSD: sftp.c,v 1.66 2005/08/08 13:22:48 jaredy Exp $"); |
20 | 20 | ||
21 | #ifdef USE_LIBEDIT | 21 | #ifdef USE_LIBEDIT |
22 | #include <histedit.h> | 22 | #include <histedit.h> |
@@ -1237,7 +1237,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) | |||
1237 | char *dir = NULL; | 1237 | char *dir = NULL; |
1238 | char cmd[2048]; | 1238 | char cmd[2048]; |
1239 | struct sftp_conn *conn; | 1239 | struct sftp_conn *conn; |
1240 | int err; | 1240 | int err, interactive; |
1241 | EditLine *el = NULL; | 1241 | EditLine *el = NULL; |
1242 | #ifdef USE_LIBEDIT | 1242 | #ifdef USE_LIBEDIT |
1243 | History *hl = NULL; | 1243 | History *hl = NULL; |
@@ -1303,6 +1303,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) | |||
1303 | setlinebuf(infile); | 1303 | setlinebuf(infile); |
1304 | #endif | 1304 | #endif |
1305 | 1305 | ||
1306 | interactive = !batchmode && isatty(STDIN_FILENO); | ||
1306 | err = 0; | 1307 | err = 0; |
1307 | for (;;) { | 1308 | for (;;) { |
1308 | char *cp; | 1309 | char *cp; |
@@ -1310,20 +1311,28 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) | |||
1310 | signal(SIGINT, SIG_IGN); | 1311 | signal(SIGINT, SIG_IGN); |
1311 | 1312 | ||
1312 | if (el == NULL) { | 1313 | if (el == NULL) { |
1313 | printf("sftp> "); | 1314 | if (interactive) |
1315 | printf("sftp> "); | ||
1314 | if (fgets(cmd, sizeof(cmd), infile) == NULL) { | 1316 | if (fgets(cmd, sizeof(cmd), infile) == NULL) { |
1315 | printf("\n"); | 1317 | if (interactive) |
1318 | printf("\n"); | ||
1316 | break; | 1319 | break; |
1317 | } | 1320 | } |
1318 | if (batchmode) /* Echo command */ | 1321 | if (!interactive) { /* Echo command */ |
1319 | printf("%s", cmd); | 1322 | printf("sftp> %s", cmd); |
1323 | if (strlen(cmd) > 0 && | ||
1324 | cmd[strlen(cmd) - 1] != '\n') | ||
1325 | printf("\n"); | ||
1326 | } | ||
1320 | } else { | 1327 | } else { |
1321 | #ifdef USE_LIBEDIT | 1328 | #ifdef USE_LIBEDIT |
1322 | const char *line; | 1329 | const char *line; |
1323 | int count = 0; | 1330 | int count = 0; |
1324 | 1331 | ||
1325 | if ((line = el_gets(el, &count)) == NULL || count <= 0) | 1332 | if ((line = el_gets(el, &count)) == NULL || count <= 0) { |
1326 | break; | 1333 | printf("\n"); |
1334 | break; | ||
1335 | } | ||
1327 | history(hl, &hev, H_ENTER, line); | 1336 | history(hl, &hev, H_ENTER, line); |
1328 | if (strlcpy(cmd, line, sizeof(cmd)) >= sizeof(cmd)) { | 1337 | if (strlcpy(cmd, line, sizeof(cmd)) >= sizeof(cmd)) { |
1329 | fprintf(stderr, "Error: input line too long\n"); | 1338 | fprintf(stderr, "Error: input line too long\n"); |
@@ -1346,6 +1355,9 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2) | |||
1346 | } | 1355 | } |
1347 | xfree(pwd); | 1356 | xfree(pwd); |
1348 | 1357 | ||
1358 | if (el != NULL) | ||
1359 | el_end(el); | ||
1360 | |||
1349 | /* err == 1 signifies normal "quit" exit */ | 1361 | /* err == 1 signifies normal "quit" exit */ |
1350 | return (err >= 0 ? 0 : -1); | 1362 | return (err >= 0 ? 0 : -1); |
1351 | } | 1363 | } |