| tAutomatically add - prefix, try to make output clearer. - plan9port - [fork] P… | |
| git clone git://src.adamsgaard.dk/plan9port | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit 3ae1a866feb2dcaa31877ddb924687eea6c58ec4 | |
| parent 65fb6fb74cb14afcc8b7040fcc6f253dec622fd0 | |
| Author: rsc <devnull@localhost> | |
| Date: Thu, 24 Mar 2005 05:17:21 +0000 | |
| Automatically add - prefix, try to make output clearer. | |
| Diffstat: | |
| M src/cmd/sftpcache.c | 22 +++++++++++++++------- | |
| 1 file changed, 15 insertions(+), 7 deletions(-) | |
| --- | |
| diff --git a/src/cmd/sftpcache.c b/src/cmd/sftpcache.c | |
| t@@ -41,12 +41,12 @@ Brd(Biobuf *bin) | |
| buf[tot++] = c; | |
| if(c == '\n'){ | |
| buf[tot] = 0; | |
| - dprint("%s", buf); | |
| + dprint("OUT %s", buf); | |
| return buf; | |
| } | |
| if(c == ' ' && tot == 6 && memcmp(buf, "sftp> ", 5) == 0){ | |
| buf[tot] = 0; | |
| - dprint("%s\n", buf); | |
| + dprint("OUT %s\n", buf); | |
| return buf; | |
| } | |
| } | |
| t@@ -75,11 +75,17 @@ void | |
| doerrors(int fd) | |
| { | |
| char buf[100]; | |
| - int n; | |
| + int n, first; | |
| + first = 1; | |
| while((n = read(sftperr, buf, sizeof buf)) > 0){ | |
| - if(debug) | |
| + if(debug){ | |
| + if(first){ | |
| + first = 0; | |
| + fprint(2, "OUT errors:\n"); | |
| + } | |
| write(1, buf, n); | |
| + } | |
| write(fd, buf, n); | |
| } | |
| } | |
| t@@ -179,14 +185,16 @@ main(int argc, char **argv) | |
| if(n <= 0) | |
| break; | |
| dprint("CMD %s\n", cmd); | |
| - if(strcmp(cmd, "DONE") == 0) | |
| + if(strcmp(cmd, "DONE") == 0){ | |
| + fprint(fd, "DONE\n"); | |
| break; | |
| - fprint(sftpfd, "%s\n", cmd); | |
| + } | |
| + fprint(sftpfd, "-%s\n", cmd); | |
| q = Brd(&bin); | |
| if(*q==0 || q[strlen(q)-1] != '\n') | |
| sysfatal("unexpected response"); | |
| q[strlen(q)-1] = 0; | |
| - if(strcmp(q, cmd) != 0) | |
| + if(q[0] != '-' || strcmp(q+1, cmd) != 0) | |
| sysfatal("unexpected response"); | |
| while((q = Brd(&bin)) != nil){ | |
| if(strcmp(q, "sftp> ") == 0){ |