]> andersk Git - openssh.git/commitdiff
- jaredy@cvs.openbsd.org 2005/08/08 13:22:48
authordjm <djm>
Fri, 12 Aug 2005 12:16:22 +0000 (12:16 +0000)
committerdjm <djm>
Fri, 12 Aug 2005 12:16:22 +0000 (12:16 +0000)
     [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

ChangeLog
sftp.c

index b14fb33257c110d94cf76c5a5f3ca6815cbfc863..ad4ea680780f3852b7fca2b9172869d4747bf7a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [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.
diff --git a/sftp.c b/sftp.c
index 9d236074392a85b8610155b90da6b1f9859814f9..0f1aa4b54615fa292b1b2fa8fc478f72a0f844ae 100644 (file)
--- 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);
 }
This page took 0.41482 seconds and 5 git commands to generate.