Christian Brabandt wrote:
> On Tue, October 23, 2012 21:48, Marc Weber wrote:
> > What magic is gvim doing to hide its documentation?
> >
> > I understand this:
> > [marc@nixos:~]$ gvim --help 1> /tmp/file; ls -l /tmp/file
> > 3326 (bytes in /tmp/file)
> >
> > I'd expect stdout to be printed to my console
> > [marc@nixos:~]$ gvim --help 2> /tmp/file; ls -l /tmp/file
> > 0 (bytes in /tmp/file)
> >
> > I'd expect stdout to be written to the file
> > [marc@nixos:~]$ bash -c "(gvim --help) >/tmp/file 2>&1" ; ls -l /tmp/file
> > 0 (bytes in /tmp/file)
> >
> > So why is gvim hiding its documentation when stderr is redirected to a
> > file?
>
> Vim checks, whether stderr is a terminal and if not, it doesn't
> display anything and quits. But vim with a GNOME gui, works as
> expected. That is indeed a little bit strange.
>
> Bram, the problem is in command_line_scan() when parsing the command
> line options, gui.starting is set to FALSE only for GNOME builts, but
> in mch_msg(), which is used for displaying the usage()
> function explicitly checks for the GUI versions:
> (isatty(2) || !(gui.in_use || gui.starting))
>
> Since for non-gnome gui versions, gui.starting is still true, the
> whole conditions becomes false and vim exits without displaying
> anything.
>
> This patch should make it work with all gui versions of Vim:
>
> diff --git a/src/main.c b/src/main.c
> --- a/src/main.c
> +++ b/src/main.c
> @@ -1933,8 +1933,9 @@
> break;
>
> case 'h': /* "-h" give help message */
> -#ifdef FEAT_GUI_GNOME
> - /* Tell usage() to exit for "gvim". */
> +#ifdef FEAT_GUI
> + /* Tell usage() to exit for "gvim".
> + * but make sure usage() is displayed, even if stderr is
> redirected */
> gui.starting = FALSE;
> #endif
> usage();
>
> This fixes only gvim -h 2>/dev/null while gvim --help 2>/dev/null
> still only displays the GNOME specific options (or nothing for
> non-gnome builts)
The idea is that when there is no terminal, gvim is started from the
desktop, the output of --help is displayed in a GUI window. Thus you
can't set gui.starting to FALSE in general.
Vim detects that there is no terminal by checking if stderr is a tty. I
don't know if there is a more reliable check. Perhaps checking whether
stdin is a tty?
GNOME has some weird startup stuff that exits in unexpected ways. I
don't recall the details.
The solution is somewhere else...
--
A consultant is a person who takes your money and annoys your employees while
tirelessly searching for the best way to extend the consulting contract.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php