From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 206 invoked by alias); 27 Jul 2013 17:25:15 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17897 Received: (qmail 17970 invoked from network); 27 Jul 2013 17:25:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 74.125.82.170 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=P0CEhRsDqK01GnPGHO35q/M97Qc0AsBWhMLCAQxe5gM=; b=oy5sh1sxkQ3VgiNh1lkFRDokuHv8lxStuDThqhbPmtDgwlz+tCJ42mzmN67CYYI+BY HjpTmUiFcjQtEufMiCRj8cpxHRlS8fydZ4sdTUIPwY6Mltq7JeCeIhWc57j3jWI3hi8q tbMBQt0toI6Tgmcllc29lF/Ph2m5u1x4nVNY7jbvclyaKlX0Z1FboWG7iYyxesW07BXf vz7QBdaEl2x7V1WnTEyk+x/AYc+Wc8fdLziBr86ucN/A22/lHCUn0TPFZIecjKfyp1So Lpcxlz8z7lnAcBgr+desHW+ditlGEo+RzKmql/CrL6lPwno3sqCQYcSHtlXo6bAYmnax JWQw== X-Received: by 10.194.83.74 with SMTP id o10mr9768403wjy.95.1374942657392; Sat, 27 Jul 2013 09:30:57 -0700 (PDT) Date: Sat, 27 Jul 2013 17:30:55 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: zsh-users@zsh.org Subject: Re: print to the terminal in zle Message-ID: <20130727163055.GB14201@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , zsh-users@zsh.org References: <20130726134811.GA14136@chaz.gmail.com> <20130726203931.3e05f151@pws-pc.ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130726203931.3e05f151@pws-pc.ntlworld.com> User-Agent: Mutt/1.5.21 (2010-09-15) 2013-07-26 20:39:31 +0100, Peter Stephenson: > On Fri, 26 Jul 2013 14:48:11 +0100 > Stephane Chazelas wrote: > > recently, Debian broke some of my scripts using ZLE in `zsh -i` by adding: > > > > function zle-line-init () { > > emulate -L zsh > > printf '%s' ${terminfo[smkx]} > > } > > > > To /etc/zsh/zshrc > > > > That smkx escape sequence is printed to stdout instead of the terminal. > > It's just occurred to me that maybe zle special functions should be run > with stdout and stdin set explicitly to the terminal. Arguably they > have no business knowing about a redirected stdout or stdin since they > run in a context where that's meaningless. stderr would be good enough > for debugging. [...] In my script (http://www.zsh.org/mla/users/2007/msg01187.html), I need to be able to access stdout from a zle function, though I could change it to use another fd (my modified "accept-line" writes the $BUFFER to stdout that goes to a pipe) (and yes, there was a reason to write it in such a convoluted way, but that was years ago) Given that ZLE can be used from "vared" to implement a line editor for something else than the shell prompt, where a system of functions can be defined by the user, it feels wrong to hide stdout from those functions. Think of vared var | { some processing that interacts with what widgets write to stdout } Now, I agree it's a clean way to expose the terminal to the ZLE widgets would they need to send/recv data to/from it, and one can dup to another fd if they need to access the original stdin/out. vared var 3>&1 | ... or use a coproc... -- Stephane