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)
Assigning to me...
I like it. We'll try it out in ~arch for a while, csh-1.29-r2 contains the patch.
Currently in ~arch, will mark stable shortly.