diff options
author | Damien Miller <djm@mindrot.org> | 2005-08-12 22:16:22 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2005-08-12 22:16:22 +1000 |
commit | 0e2c1028583da14b61e311fdcf8859f4335fc3be (patch) | |
tree | 2a03e33271cb66c6374115d34c42a2023a8e3f37 /sftp.c | |
parent | 8e489484a1dbb8e2a15855e04b5897e33b2480c4 (diff) | |
download | openssh-git-0e2c1028583da14b61e311fdcf8859f4335fc3be.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
Diffstat (limited to 'sftp.c')
-rw-r--r-- | sftp.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -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); } |