aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rtty.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/rtty.c b/rtty.c
index 50b79e8..297b699 100644
--- a/rtty.c
+++ b/rtty.c
@@ -130,14 +130,16 @@ main(int argc, char *argv[])
* Escaped commands are recognized only after a
* remote shell prompt.
*/
- if(!(escape && bufin[0] == '!'
+ if(escape && bufin[0] == '!'
&& (strcmp(bufout+strlen(bufout)-2, "$ ") == 0
|| strcmp(bufout+strlen(bufout)-2, "% ") == 0
- || strcmp(bufout+strlen(bufout)-2, "# ") == 0))){
- dprintf(fdin, "%s", bufin);
- continue;
- }
+ || strcmp(bufout+strlen(bufout)-2, "# ") == 0))
+ goto escape;
+
+ dprintf(fdin, "%s", bufin);
+ continue;
+escape:
/*
* Get remote working directory. (The response
* looks like "pwd\n(directory)\n(prompt)".)
@@ -169,8 +171,7 @@ main(int argc, char *argv[])
found:
if(eargv[i+1]){
- fprintf(stderr,
- "more than one file given\n");
+ fprintf(stderr, "more than one file given\n");
goto done;
}
@@ -244,7 +245,7 @@ done:
}
/*
- * System output is read from the output pipe and copied
+ * Remote output is read from the output pipe and copied
* to standard out for the user to see.
*/
FD_SET(fdout, &rfds1);
@@ -257,6 +258,7 @@ done:
* skipped, assuming that bufin contains the
* command in its entirety.
*/
+ i = 0;
p = bufin;
q = bufout;
for(;;){
@@ -264,15 +266,19 @@ done:
q++;
break;
}
- if(*q == 13){
+ if(*q == '\r'){
q++;
continue;
}
+ if(*p == '\t' && strspn(q, " ") >= 8-i%8){
+ p++; q += 8-i%8; i += 8-i%8;
+ continue;
+ }
if(*p != *q){
q = bufout;
break;
}
- p++; q++;
+ p++; q++; i++;
}
/* Don't skip the echo again. */