From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7718 invoked by alias); 12 Jun 2017 04:15:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41271 Received: (qmail 16807 invoked from network); 12 Jun 2017 04:15:39 -0000 X-Qmail-Scanner-Diagnostics: from mout.gmx.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.227.17.20):SA:0(-0.0/5.0):. Processed in 2.329827 secs); 12 Jun 2017 04:15:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: llua@gmx.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at gmx.com designates 212.227.17.20 as permitted sender) Subject: Re: [PATCH] avoid closed stdin() in zle widgets To: zsh-workers@zsh.org References: <20170611182045.GA5318@chaz.gmail.com> From: Eric Cook Message-ID: Date: Mon, 12 Jun 2017 00:15:20 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170611182045.GA5318@chaz.gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:qpEMSzgK+q+k+Qc2jhr89l3ymUaGZzvEjX118RMI75Vvdg5tVd6 YzvaifM87G6FSG+/lMmIoHk8miS2l9zVeCOHF3OeNUZsZZ70WdZsJZ5UoD+TDU2O3uE3QMW Rs0euQP8gA0eYG36I5R9JASt1jGSgEPWJxPb/HiR9BwJNEJGQLQVFpuQDMwcXyenWhMh0UW batx6rbfwGt92jnN1XG5Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:dtSAlx6Wi5U=:R6AUflmSd8eprADTwNHKtc yLXwK95fCUQqxwdVMgX0isHcQeOWijo1QPHDuQWI6mq+yDK/JFX8qyyggbvtnNvk+A/OCWWBp NwAgDaAUJ9RR9MHlNzH0f+8wC3QUyf2W5NZyniSjlqdDxZ8tj8/cNRK4VNQUSEX9NdofVXuAn FEGEoTFgnDUoHvDuIaLmqx4IB46IyC4AUKfkhxtkH0LH3sASu3CwqMeoSixStG+ClFnoT2126 c07Zx+nn2IO6jdMS20Tbhi57TFff6aLp6Kkj0iiPkbPDIsh8lfspxfx9Gal30EXOgGtu8kVww g6DqC7fA5LV0IjSPwYRl1TvFCwNrOOCqsvXtucn0tAb2UsxtoCndVDpfBK7oVWLHgJ/I6PiXS VTkka3Pq39oECd6Z0fuIAmaeaKwm+Y3cnbUnzLEIfkoqzo1lJBw3olVjNCFJHeJQ89Rt36zXF GCyWy6FyhPeJTlwqGrQSQaD+q/aucAwHAGDM87NJO2x8EvF/X7zyTSwTshqdCNX7sCcEZq3Zp 7yKn4PR1ykiFmU+DGz9C656sEKxMhESBLLOf6UsK4Yk5UZYHlABT27U9i9rbP+E76x7doUKHx Z8CaU70QH6zEsgUg4xxxRHJwwznn89lBCmfTgk3nMgfCI4uSfMzZDEPpbJcr2OkS3DwoOQwU+ agjgjQFXiuvtMEoBcNePG6N2V1NUm8UMUPK0nhUusjhLuNUoe8wwKVbdFZH8h0fzjham6CzNZ ibhiVBol08+lurHGdmsUpFFoLeoA6KgEXdgK37SRqsj/am0+HBTQIjTFGpCTMQY3uBPnpycmQ ZtPWLZm On 06/11/2017 02:20 PM, Stephane Chazelas wrote: > Hello, > > in zle widgets, stdin currently appears to be closed. That's > generally not a good idea to close fds 0, 1, 2 as many commands > are confused when the files they open suddenly become their > stdin/stdout/stderr because the first free fd is 0/1/2. > > See > > https://unix.stackexchange.com/q/370475 It is documented to work like that in zshzle --- USER-DEFINED WIDGETS 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 zle builtin command. The standard input of the function is closed to prevent external commands from unintentionally blocking ZLE by reading from the terminal, but read -k or 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.