* Calling interactive command inside widget
@ 2016-04-12 21:58 Evgeny Zajcev
2016-04-13 8:41 ` Peter Stephenson
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Evgeny Zajcev @ 2016-04-12 21:58 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
I always had next widget in my zprofile
my-run-help () {
words=(${=BUFFER})
if [[ $words[1] = sudo ]]
then
run-help $words[2]
else
run-help $words[1]
fi
zle reset-prompt
}
zle -N my-run-help
bindkey "^[^[h" run-help
so when I type in prompt something like "sudo adduser xxx" and want
interactive help on adduser I just press M-h
It was always working, however on my fresh Ubuntu install, I've got:
adduser is /usr/sbin/adduser
Missing filename ("less --help" for help)
I'v created simple widget like:
just-run-man () {
man man
}
zle -N just-run-man
bindkey "^[^[h" just-run-man
And also got
Missing filename ("less --help" for help)
What should I do to get desired behaviour?
I'm using zsh 5.0.2 (x86_64-pc-linux-gnu) under Ubuntu, my PAGER is less
thanks
--
lg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling interactive command inside widget
2016-04-12 21:58 Calling interactive command inside widget Evgeny Zajcev
@ 2016-04-13 8:41 ` Peter Stephenson
2016-04-13 17:55 ` Bart Schaefer
2016-04-16 8:21 ` frederik
2016-04-20 8:44 ` Sebastian Gniazdowski
2 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2016-04-13 8:41 UTC (permalink / raw)
To: zsh-users
On Wed, 13 Apr 2016 00:58:04 +0300
Evgeny Zajcev <lg.zevlg@gmail.com> wrote:
> I'v created simple widget like:
>
> just-run-man () {
> man man
> }
> zle -N just-run-man
> bindkey "^[^[h" just-run-man
>
> And also got
>
> Missing filename ("less --help" for help)
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.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling interactive command inside widget
2016-04-13 8:41 ` Peter Stephenson
@ 2016-04-13 17:55 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2016-04-13 17:55 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling interactive command inside widget
2016-04-12 21:58 Calling interactive command inside widget Evgeny Zajcev
2016-04-13 8:41 ` Peter Stephenson
@ 2016-04-16 8:21 ` frederik
2016-04-20 8:44 ` Sebastian Gniazdowski
2 siblings, 0 replies; 5+ messages in thread
From: frederik @ 2016-04-16 8:21 UTC (permalink / raw)
To: Evgeny Zajcev; +Cc: zsh-users
This is a bit tangential to your bug, but I don't know if you know
about various run-help-CMD helper functions:
http://stackoverflow.com/questions/32293262/how-to-make-zsh-run-help-to-ignore-sudo-and-get-help-about-the-following-com
I just learned about these a month ago.
Cheers,
Frederick
On Wed, Apr 13, 2016 at 12:58:04AM +0300, Evgeny Zajcev wrote:
> I always had next widget in my zprofile
>
> my-run-help () {
> words=(${=BUFFER})
> if [[ $words[1] = sudo ]]
> then
> run-help $words[2]
> else
> run-help $words[1]
> fi
> zle reset-prompt
> }
>
> zle -N my-run-help
> bindkey "^[^[h" run-help
>
> so when I type in prompt something like "sudo adduser xxx" and want
> interactive help on adduser I just press M-h
>
> It was always working, however on my fresh Ubuntu install, I've got:
>
> adduser is /usr/sbin/adduser
> Missing filename ("less --help" for help)
>
>
> I'v created simple widget like:
>
> just-run-man () {
> man man
> }
> zle -N just-run-man
> bindkey "^[^[h" just-run-man
>
> And also got
>
> Missing filename ("less --help" for help)
>
> What should I do to get desired behaviour?
>
> I'm using zsh 5.0.2 (x86_64-pc-linux-gnu) under Ubuntu, my PAGER is less
>
> thanks
>
> --
> lg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Calling interactive command inside widget
2016-04-12 21:58 Calling interactive command inside widget Evgeny Zajcev
2016-04-13 8:41 ` Peter Stephenson
2016-04-16 8:21 ` frederik
@ 2016-04-20 8:44 ` Sebastian Gniazdowski
2 siblings, 0 replies; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-04-20 8:44 UTC (permalink / raw)
To: Evgeny Zajcev; +Cc: Zsh Users
It's about having terminal attached to 0. I wrote a wrapper that runs
given interactive command from within Zle:
https://github.com/psprint/zsh-navigation-tools/blob/master/znt-usetty-wrapper
It's to be used in following way:
znt-usetty-wrapper some-interactive-command "$@"
via some widget file-function, like here:
https://github.com/psprint/zsh-navigation-tools/blob/master/znt-kill-widget
This looks quite like an overkill when compared to Bart's simple
</dev/tty, but it does some checking and searches for terminal also
via 2. Also, it restores previous 0 state. Maybe you'll like it
Best regards,
Sebastian Gniazdowski
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-20 8:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-12 21:58 Calling interactive command inside widget Evgeny Zajcev
2016-04-13 8:41 ` Peter Stephenson
2016-04-13 17:55 ` Bart Schaefer
2016-04-16 8:21 ` frederik
2016-04-20 8:44 ` Sebastian Gniazdowski
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).