From 0jacobnk.sgosoft at chiark.greenend.org.uk Sun Apr 3 21:01:07 2005 From: 0jacobnk.sgosoft at chiark.greenend.org.uk (Jacob Nevins) Date: Sun, 3 Apr 2005 21:01:07 +0100 Subject: with-readline-0.1 on Debian woody In-Reply-To: References: <20050326174552.GA11811@chiark.greenend.org.uk> Message-ID: <20050403200107.GB21061@chiark.greenend.org.uk> --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The attached patch is necessary to compile on Debian woody, whose readline doesn't appear to have rl_replace_line(). However, I haven't been able to test it properly due to other problems; see below. When running with the above patch on Debian woody (e.g., chiark), trying "with-readline -- sftp hostname", I have the following problems: - my password is echoed at the password prompt (I'm using password authentication in SSH) - if I ^C at the password prompt after having typed something, I get FATAL: error writing to pty master: Bad file descriptor (9) and my terminal is left in some bad non-echoing mode, requiring "stty sane" to fix. This doesn't happen if I ^C before typing anything at the prompt; then I get "sftp: Interrupt". I haven't investigated these issues, on the grounds that you're more likely to be familiar with the pty horrors than I am. (configure has set PTY_UNIX98 and not PTY_BSD.) I also get the following warnings and more, but it seems unlikely that that's your fault. I haven't investigated this either; it sounds harmless enough. In file included from with-readline.h:34, from with-readline.c:21: /usr/include/stropts.h:61: warning: redundant redeclaration of `ioctl' in same scope /usr/include/sys/ioctl.h:42: warning: previous declaration of `ioctl' In file included from with-readline.h:43, from with-readline.c:21: /usr/include/unistd.h:966: warning: redundant redeclaration of `ctermid' in same scope /usr/include/stdio.h:583: warning: previous declaration of `ctermid' In file included from with-readline.h:52, from with-readline.c:21: /usr/include/readline/readline.h:313: warning: redundant redeclaration of `rl_make_bare_keymap' in same scope /usr/include/readline/keymaps.h:73: warning: previous declaration of `rl_make_bare_keymap' --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="woody.diff" --- with-readline.c.orig Sun Apr 3 20:39:11 2005 +++ with-readline.c Sun Apr 3 20:48:23 2005 @@ -415,7 +415,9 @@ fatal(err, "error writing to pty master"); free(s); } - rl_replace_line("", 1); + rl_line_buffer[0] = '\0'; + rl_point = rl_mark = rl_end = 0; + rl_free_undo_list(); } } if(tcsetattr(0, TCSANOW, &original_termios) < 0) --jRHKVT23PllUwdXP-- From rjk at terraraq.org.uk Sat Apr 23 16:21:23 2005 From: rjk at terraraq.org.uk (Richard Kettlewell) Date: 23 Apr 2005 16:21:23 +0100 Subject: with-readline-0.1 on Debian woody In-Reply-To: <20050403200107.GB21061@chiark.greenend.org.uk> References: <20050326174552.GA11811@chiark.greenend.org.uk> <20050403200107.GB21061@chiark.greenend.org.uk> Message-ID: <84is2d1pu4.fsf@rjk.greenend.org.uk> Jacob Nevins <0jacobnk.sgosoft@chiark.greenend.org.uk> writes: > The attached patch is necessary to compile on Debian woody, whose > readline doesn't appear to have rl_replace_line(). However, I haven't > been able to test it properly due to other problems; see below. I've applied the patch, thankyou. > When running with the above patch on Debian woody (e.g., chiark), trying > "with-readline -- sftp hostname", I have the following problems: > - my password is echoed at the password prompt (I'm using password > authentication in SSH) > - if I ^C at the password prompt after having typed something, I get > FATAL: error writing to pty master: Bad file descriptor (9) > and my terminal is left in some bad non-echoing mode, requiring > "stty sane" to fix. > This doesn't happen if I ^C before typing anything at the prompt; > then I get "sftp: Interrupt". > > I haven't investigated these issues, on the grounds that you're more > likely to be familiar with the pty horrors than I am. (configure has set > PTY_UNIX98 and not PTY_BSD.) I've been thinking about this for a while. The ideal would be for with-readline to notice the intermediate pty changing mode and adjusting its own terminal and its behaviour to reflect this. Currently it makes the intermediate pty noecho, so that it doesn't get the characters it sends back (because it's printed them already when they were being entered). Erasing the line and allowing the echo to re-print it would require care with control characters and could be visually disturbing, particularly over slow links. My best idea so far is to temporarily disable echo when sending the input line over the intermediate pty, and then restore the terminal settings immediately afterwards. It might be necessarily to temporary stop the child process group so it doesn't start a race by messing with terminal settings as soon as its read the input. Another approach might be to inhibit readline from issuing a newline, and instead sending most of the line noecho but restoring terminal settings for the newline, so the terminal is back as the subprocess expects by the time read() completes. I've not tried any of this yet so I don't know how well it will work. > I also get the following warnings and more, but it seems unlikely that > that's your fault. I haven't investigated this either; it sounds > harmless enough. > > In file included from with-readline.h:34, > from with-readline.c:21: > /usr/include/stropts.h:61: warning: redundant redeclaration of `ioctl' in same scope > /usr/include/sys/ioctl.h:42: warning: previous declaration of `ioctl' > In file included from with-readline.h:43, > from with-readline.c:21: > /usr/include/unistd.h:966: warning: redundant redeclaration of `ctermid' in same scope > /usr/include/stdio.h:583: warning: previous declaration of `ctermid' > In file included from with-readline.h:52, > from with-readline.c:21: > /usr/include/readline/readline.h:313: warning: redundant redeclaration of `rl_make_bare_keymap' in same scope > /usr/include/readline/keymaps.h:73: warning: previous declaration of `rl_make_bare_keymap' They look harmless to me. -- http://www.greenend.org.uk/rjk/ From rjk at terraraq.org.uk Sat Apr 23 16:21:23 2005 From: rjk at terraraq.org.uk (Richard Kettlewell) Date: 23 Apr 2005 16:21:23 +0100 Subject: with-readline-0.1 on Debian woody In-Reply-To: <20050403200107.GB21061@chiark.greenend.org.uk> References: <20050326174552.GA11811@chiark.greenend.org.uk> <20050403200107.GB21061@chiark.greenend.org.uk> Message-ID: <84is2d1pu4.fsf@rjk.greenend.org.uk> Jacob Nevins <0jacobnk.sgosoft@chiark.greenend.org.uk> writes: > The attached patch is necessary to compile on Debian woody, whose > readline doesn't appear to have rl_replace_line(). However, I haven't > been able to test it properly due to other problems; see below. I've applied the patch, thankyou. > When running with the above patch on Debian woody (e.g., chiark), trying > "with-readline -- sftp hostname", I have the following problems: > - my password is echoed at the password prompt (I'm using password > authentication in SSH) > - if I ^C at the password prompt after having typed something, I get > FATAL: error writing to pty master: Bad file descriptor (9) > and my terminal is left in some bad non-echoing mode, requiring > "stty sane" to fix. > This doesn't happen if I ^C before typing anything at the prompt; > then I get "sftp: Interrupt". > > I haven't investigated these issues, on the grounds that you're more > likely to be familiar with the pty horrors than I am. (configure has set > PTY_UNIX98 and not PTY_BSD.) I've been thinking about this for a while. The ideal would be for with-readline to notice the intermediate pty changing mode and adjusting its own terminal and its behaviour to reflect this. Currently it makes the intermediate pty noecho, so that it doesn't get the characters it sends back (because it's printed them already when they were being entered). Erasing the line and allowing the echo to re-print it would require care with control characters and could be visually disturbing, particularly over slow links. My best idea so far is to temporarily disable echo when sending the input line over the intermediate pty, and then restore the terminal settings immediately afterwards. It might be necessarily to temporary stop the child process group so it doesn't start a race by messing with terminal settings as soon as its read the input. Another approach might be to inhibit readline from issuing a newline, and instead sending most of the line noecho but restoring terminal settings for the newline, so the terminal is back as the subprocess expects by the time read() completes. I've not tried any of this yet so I don't know how well it will work. > I also get the following warnings and more, but it seems unlikely that > that's your fault. I haven't investigated this either; it sounds > harmless enough. > > In file included from with-readline.h:34, > from with-readline.c:21: > /usr/include/stropts.h:61: warning: redundant redeclaration of `ioctl' in same scope > /usr/include/sys/ioctl.h:42: warning: previous declaration of `ioctl' > In file included from with-readline.h:43, > from with-readline.c:21: > /usr/include/unistd.h:966: warning: redundant redeclaration of `ctermid' in same scope > /usr/include/stdio.h:583: warning: previous declaration of `ctermid' > In file included from with-readline.h:52, > from with-readline.c:21: > /usr/include/readline/readline.h:313: warning: redundant redeclaration of `rl_make_bare_keymap' in same scope > /usr/include/readline/keymaps.h:73: warning: previous declaration of `rl_make_bare_keymap' They look harmless to me. -- http://www.greenend.org.uk/rjk/ From ijackson at chiark.greenend.org.uk Thu Aug 25 00:16:32 2005 From: ijackson at chiark.greenend.org.uk (Ian Jackson) Date: Thu, 25 Aug 2005 00:16:32 +0100 Subject: with-readline-0.1 on Debian woody In-Reply-To: <84is2d1pu4.fsf@rjk.greenend.org.uk> References: <20050326174552.GA11811@chiark.greenend.org.uk> <20050403200107.GB21061@chiark.greenend.org.uk> <84is2d1pu4.fsf@rjk.greenend.org.uk> Message-ID: <17164.65488.753807.980577@chiark.greenend.org.uk> In article <84is2d1pu4.fsf@rjk.greenend.org.uk>, Richard Kettlewell wrote: >Erasing the line and allowing the echo to re-print it would require >care with control characters and could be visually disturbing, >particularly over slow links. You could position the cursor back at the beginning of the line and allow the echo to overprint the text that readline had already printed. Then you'd just see some cursor motion but no disappearing and reappearing text. Ian.