From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25128 invoked by alias); 13 Apr 2016 17:55:40 -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: 21443 Received: (qmail 26426 invoked from network); 13 Apr 2016 17:55: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=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=QvuQct/eZ5iWd+mJlY4BsGGVVbRCgzq1mD4rDSvcEeA=; b=hhB31I2hlW4mp1aRQZRoQai1OTUgMDpHdRtfihzONfB7zrPdiLHO1pqbD8h9bi3biz UCY77YsuEk+Bh4WfrKPCTzSkbQepCLAKijEa2y298x1+dDrcrHvu7cTBOWij5M6Vlm/Y l6umf6DqgIRT8ZlO5fY7hMj6pOK6emFiE/Pe0AH+j8sSl6TyCjT7zAqcYgTfXx898d54 aQZ+83Zhh3G+ryNzry3+BXcMtXrUEGkpfrpDEZM3dJPN78hj8euLZsUm5VKZFEIlHvrH Ij1ZnOkKmsadFcDovTJJe8ascmYXwns1JC3fgFc9FT8ZVAdfTq3s4He1Jz5Jj6d/C968 /v6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=QvuQct/eZ5iWd+mJlY4BsGGVVbRCgzq1mD4rDSvcEeA=; b=Y6fhLOyeBpHr5kJEL0BboqXXyzGFHtCnOd6LopcNSrzhixoDpRpdg+sVVb1linigtD SMlQTjwWaCcQj+XbaompnBMw7DMfT2Mf/LFIRD9JRSWq3onFEkYJMXDg/g7sA8ZMkBrt v0yRh3sFgRyxz+gd5vsi1viaVwtooCXWbP+IDs5q1WGQvNNI+JLdceItLyt3/RDkpeMI hC3dc+80FPqWPV4lPt+jj7vwL1Fx2S2HjVXt5PGbO1k7u9sak4Or6QrYczjuNfsUCjGL gZdyXUkz/eZ8SAUn6XcyPN6TQQr5TTtL6UKtD4KmLj6IGo/VRcxB8Xp8JbfJSWn0dJ4C SlIw== X-Gm-Message-State: AOPr4FXnYp89eEPMrnGLwL2PJymv3lXiVjzjov6gDDYqg+B5ZikalFdG0BG1jQH+QD2kBw== X-Received: by 10.98.80.206 with SMTP id g75mr14683164pfj.127.1460570133011; Wed, 13 Apr 2016 10:55:33 -0700 (PDT) From: Bart Schaefer Message-Id: <160413105532.ZM31657@torch.brasslantern.com> Date: Wed, 13 Apr 2016 10:55:32 -0700 In-Reply-To: <20160413094152.660d42a9@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: Calling interactive command inside widget" (Apr 13, 9:41am) References: <20160413094152.660d42a9@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Calling interactive command inside widget MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 13, 9:41am, Peter Stephenson wrote: } } There's nothing much to go wrong in this ultra-simple example. I would } suspect it's a problem not visible here, e.g. something associated } with less like the LESSOPEN variable has gone haywire. To investigate, } try setting PAGER=more and see if that works. I can reproduce from zsh -f on my older Ubuntu -- here is xtrace output: burner% ls +my-run-help:2> words=( ls ) +my-run-help:3> [[ ls == sudo ]] +my-run-help:7> man ls Missing filename ("less --help" for help) +my-run-help:9> zle reset-prompt burner% which man /usr/bin/man Exporting PAGER=more silences the error but does not display a man page. I have no LESSOPEN variable. I replaced "man" with a function wrapper that captures strace and then ran "man" from the command line and again from the widget. Both times "man" runs "pager -s" (which is a symlink through /etc/alternatives to "less"). However, in the widget case, open("/dev/tty") returns 0, implying that the standard input is closed, whereas in the command-line case the same open() returns 3. [This is from inside the forked "less".] Looking more closely, "man" itself is invoked with standard input closed which causes all sorts of confusion with its handling of pipes to all the sub-processes it forks off (gunzip, nroff, etc.). You can trivially reproduce the error with: burner% man ls <&- Missing filename ("less --help" for help) burner% ( man ls | less ) <&- col: Bad file descriptor This seems like a bug in "man" that should be reported to somebody, at least Ubuntu if not upstream to Debian. Meanwhile to fix the widget, just re-open /dev/tty: my-run-help () { words=(${=BUFFER}) if [[ $words[1] = sudo ]] then run-help $words[2] else run-help $words[1] fi < /dev/tty zle reset-prompt } You may want to throw a "zle -I" in there, but perhaps reset-prompt makes it unnecessary.