From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5744 invoked from network); 10 May 2000 10:23:58 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 May 2000 10:23:58 -0000 Received: (qmail 27155 invoked by alias); 10 May 2000 10:23:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11297 Received: (qmail 27105 invoked from network); 10 May 2000 10:23:03 -0000 From: "Bart Schaefer" Message-Id: <1000510102231.ZM2598@candle.brasslantern.com> Date: Wed, 10 May 2000 10:22:31 +0000 In-Reply-To: <200005100720.JAA05611@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Re: closing stdin (Re: _make suppress error on OpenBSD.)" (May 10, 9:20am) References: <200005100720.JAA05611@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: Re: closing stdin (Re: _make suppress error on OpenBSD.) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 10, 9:20am, Sven Wischnowsky wrote: } Subject: Re: closing stdin (Re: _make suppress error on OpenBSD.) } } Bart Schaefer wrote: } } > I've long forgotten (if I ever knew) why the stdin of ZLE functions is } > closed. } } This was done (by me) in 6484. For messages leading up to this, see: } 6462 etc. Oh, goody, so it was even my idea. Sigh. This should be documented somewhere (for both completion and widgets); I just tried searching the docs for the string "close" starting at "Zsh Line Editor" and except for a couple of times in "enclosed" it's not mentioned until you hit Zftp. It probably would have saved Peter some grief when trying to answer that recent vi question on zsh-users. These may not be the best places to mention it, but they were the closest that I could find. Index: Doc/Zsh/compwid.yo =================================================================== @@ -12,22 +12,27 @@ example(zle -C complete expand-or-complete completer) -defines a widget named tt(complete). When this widget is bound to a key -using the tt(bindkey) builtin command defined in the tt(zsh/zle) module -(see -ifzman(zmanref(zshzle))\ -ifnzman(noderef(Zsh Line Editor))\ -), typing that key will call the shell function tt(completer). This -function is responsible for generating the possible matches using the -builtins described below. Once the function returns, the completion code -takes over control again and treats the matches as the builtin widget -tt(expand-or-complete) would do. For this second argument, the name of any -of the builtin widgets that handle completions can be given: +defines a widget named `tt(complete)'. The second argument is the name +of any of the builtin widgets that handle completions: tt(complete-word), tt(expand-or-complete), tt(expand-or-complete-prefix), tt(menu-complete), tt(menu-expand-or-complete), tt(reverse-menu-complete), tt(list-choices), or tt(delete-char-or-list). Note that this will still work even if the widget in question has been rebound. + +When this newly defined widget is bound to a key +using the tt(bindkey) builtin command defined in the tt(zsh/zle) module +(\ +ifzman(see zmanref(zshzle))\ +ifnzman(noderef(Zsh Line Editor))\ +), typing that key will call the shell function `tt(completer)'. This +function is responsible for generating the possible matches using the +builtins described below. As with other ZLE widgets, the function is +called with its standard input closed. + +Once the function returns, the completion code takes over control again +and treats the matches in the same manner as the specified builtin +widget, in this case tt(expand-or-complete). startmenu() menu(Special Parameters) Index: Doc/Zsh/zle.yo =================================================================== @@ -104,8 +104,10 @@ User-defined widgets, being implemented as shell functions, can execute any normal shell command. They can also run other widgets (whether built-in or user-defined) using the tt(zle) builtin command. -They can use tt(read -k) or tt(read -q) to read characters from standard -input. Finally, they can examine and edit the ZLE buffer being edited by +The standard input of the function is closed to prevent external commands +from unintentionally blocking ZLE by reading from the terminal, but +tt(read -k) or tt(read -q) can be used to read characters. Finally, +they can examine and edit the ZLE buffer being edited by reading and setting the special parameters described below. cindex(parameters, editor) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com