Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Calling interactive command inside widget
- X-seq: zsh-users 21443
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Calling interactive command inside widget
- Date: Wed, 13 Apr 2016 10:55:32 -0700
- 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==
- In-reply-to: <20160413094152.660d42a9@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAO=W_Zqi0zSqMbDODTwFBs1tb_i2j=BJvSpk0S8xKbdqOR8Qfg@mail.gmail.com> <20160413094152.660d42a9@pwslap01u.europe.root.pri>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author