Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 24290 - app-shells/csh: ^D filename completion fails to retype extant input line, fix included
Summary: app-shells/csh: ^D filename completion fails to retype extant input line, fix...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Tavis Ormandy (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-11 08:58 UTC by splite
Modified: 2003-08-20 02:01 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description splite 2003-07-11 08:58:31 UTC
app-shells/csh (the OpenBSD csh port, not tcsh) fails to retype the extant input
line after typing ^D to display file completion alternatives.  Here's a fix:

--- src/bin/csh/file.c.orig     2003-06-12 14:41:07.000000000 -0500
+++ src/bin/csh/file.c  2003-07-11 10:27:55.000000000 -0500
@@ -92,7 +92,7 @@
 
 static void setup_tty(int);
 static void back_to_col_1(void);
-static int pushback(Char *);
+static int pushback(Char *, int);
 static void catn(Char *, Char *, int);
 static void copyn(Char *, Char *, int);
 static Char filetype(Char *, Char *);
@@ -167,7 +167,7 @@
  * Push string contents back into tty queue
  */
 static int
-pushback(Char *string)
+pushback(Char *string, int doecho)
 {
     struct termios tty, tty_normal;
     char buf[TTYHOG], svchars[TTYHOG];
@@ -181,12 +181,14 @@
     (void)sigaddset(&sigset, SIGINT);
     (void)sigprocmask(SIG_BLOCK, &sigset, &osigset);
     (void)tcgetattr(SHOUT, &tty);
-    tty_normal = tty;
-    tty.c_lflag &= ~(ECHOKE | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT | ECHOCTL);
-    /* FIONREAD works only in noncanonical mode. */
-    tty.c_lflag &= ~ICANON;
-    tty.c_cc[VMIN] = 0;
-    (void)tcsetattr(SHOUT, TCSADRAIN, &tty);
+    if (!doecho) {
+        tty_normal = tty;
+        tty.c_lflag &= ~(ECHOKE | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT |
ECHOCTL);
+        /* FIONREAD works only in noncanonical mode. */
+        tty.c_lflag &= ~ICANON;
+        tty.c_cc[VMIN] = 0;
+        (void)tcsetattr(SHOUT, TCSADRAIN, &tty);
+    }
 
     for (retrycnt = 5; ; retrycnt--) {
        /*
@@ -243,7 +245,8 @@
     (void)tcsetattr(SHOUT, TCSADRAIN, &tty);
     (void)ioctl(SHOUT, FIONREAD, (ioctl_t) &i);
 #endif
-    (void)tcsetattr(SHOUT, TCSADRAIN, &tty_normal);
+    if (!doecho)
+        (void)tcsetattr(SHOUT, TCSADRAIN, &tty_normal);
     (void)sigprocmask(SIG_SETMASK, &osigset, NULL);
 
     return nsv;
@@ -377,19 +380,6 @@
     return (new);
 }
 
-/*
- * Cause pending line to be printed
- */
-static void
-retype(void)
-{
-    struct termios tty;
-
-    (void)tcgetattr(SHOUT, &tty);
-    tty.c_lflag |= PENDIN;
-    (void)tcsetattr(SHOUT, TCSADRAIN, &tty);
-}
-
 static void
 beep(void)
 {
@@ -710,15 +700,16 @@
        }
        if (command == LIST)    /* Always retype after a LIST */
            should_retype = TRUE;
+#if 0
        if (pushback(inputline))
            should_retype = TRUE;
+#endif
        if (should_retype) {
            if (command == RECOGNIZE)
                (void) fputc('\n', cshout);
            printprompt();
        }
-       if (should_retype)
-           retype();
+        pushback(inputline, should_retype);
     }
     setup_tty(OFF);
     return (num_read);

Reproducible: Always
Steps to Reproduce:
1.  type: touch foo1 foo2
2.  type: echo foo[control-D]
3.
Actual Results:  
csh outputs ("_" is the cursor):
foo1 foo2
% _

(note that "echo foo" is still in the input buffer)

Expected Results:  
csh should output ("_" is the cursor):
foo1 foo2
% echo foo_

(now I can finish typing the command)
Comment 1 Tavis Ormandy (RETIRED) gentoo-dev 2003-07-31 04:58:21 UTC
Assigning to me...
Comment 2 Tavis Ormandy (RETIRED) gentoo-dev 2003-07-31 05:29:24 UTC
I like it. We'll try it out in ~arch for a while, csh-1.29-r2 contains the patch.
Comment 3 Tavis Ormandy (RETIRED) gentoo-dev 2003-08-20 02:01:04 UTC
Currently in ~arch, will mark stable shortly.