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;
Tuesday, October 23, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment