To: vim-dev@vim.org
Subject: Patch 6.0.232
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 6.0.232
Problem:    "vim --version" prints on stderr while "vim --help" prints on
	    stdout.
Solution:   Make "vim --version" use stdout.
Files:	    runtime/doc/starting.txt, src/globals.h, src/main.c, src/message.c


*** ../vim60.231/runtime/doc/starting.txt	Tue Sep 25 21:40:38 2001
--- runtime/doc/starting.txt	Mon Feb 18 12:04:33 2002
***************
*** 1,4 ****
! *starting.txt*  For Vim version 6.0.  Last change: 2001 Sep 20
  
  
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
--- 1,4 ----
! *starting.txt*  For Vim version 6.0.  Last change: 2002 Feb 18
  
  
  		  VIM REFERENCE MANUAL    by Bram Moolenaar
***************
*** 122,131 ****
--- 122,133 ----
  
  --help							*-h* *--help*
  -h		Give usage (help) message and exit.  {not in Vi}
+ 		See |info-message| about capturing the text.
  
  							*--version*
  --version	Print version information and exit.  Same output as for
  		|:version| command.  {not in Vi}
+ 		See |info-message| about capturing the text.
  
  							*--noplugin*
  --noplugin	Skip loading plugins.  Resets the 'loadplugins' option.
***************
*** 860,865 ****
--- 862,890 ----
  redrawn in any way.  To see the message again, use the ":intro" command (if
  there is not enough room, you will see only part of it).
     To avoid the intro message on startup, add the 'I' flag to 'shortmess'.
+ 
+ 							*info-message*
+ The |--help| and |--version| arguments cause Vim to print a message and then
+ exit.  Normally the message is send to stdout, thus can be redirected to a
+ file with: >
+ 
+ 	vim --help >file
+ 
+ From inside Vim: >
+ 
+ 	:read !vim --help
+ 
+ When using gvim, it detects that it might have been started from the desktop,
+ without a terminal to show messages on.  This is detected when both stdout and
+ stderr are not a tty.  This breaks the ":read" command, as used in the example
+ above.  To make it work again, set 'shellredir' to ">" instead of the default
+ ">&": >
+ 
+ 	:set shellredir=>
+ 	:read !gvim --help
+ 
+ This still won't work for systems where gvim does not use stdout at all
+ though.
  
  ==============================================================================
  5. $VIM and $VIMRUNTIME
*** ../vim60.231/src/globals.h	Sun Feb 17 23:22:34 2002
--- src/globals.h	Mon Feb 18 11:46:05 2002
***************
*** 139,144 ****
--- 139,145 ----
  EXTERN int	msg_nowait INIT(= FALSE);   /* don't wait for this msg */
  EXTERN int	emsg_off INIT(= 0);	    /* don't display errors for now,
  					       unless 'debug' is set. */
+ EXTERN int	info_message INIT(= FALSE); /* printing informative message */
  #ifdef FEAT_EVAL
  EXTERN int	emsg_skip INIT(= 0);	    /* don't display errors for
  					       expression that is skipped */
*** ../vim60.231/src/main.c	Thu Feb  7 11:35:07 2002
--- src/main.c	Mon Feb 18 11:54:08 2002
***************
*** 521,526 ****
--- 521,527 ----
  		else if (STRICMP(argv[0] + argv_idx, "version") == 0)
  		{
  		    Columns = 80;	/* need to init Columns */
+ 		    info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
  		    list_version();
  		    mch_exit(1);
  		}
*** ../vim60.231/src/message.c	Sun Feb  3 17:31:23 2002
--- src/message.c	Mon Feb 18 11:46:11 2002
***************
*** 1545,1551 ****
  #endif
  		    *p++ = *s;
  		*p = '\0';
! 		mch_errmsg((char *)buf);
  	    }
  
  	    /* primitive way to compute the current column */
--- 1545,1554 ----
  #endif
  		    *p++ = *s;
  		*p = '\0';
! 		if (info_message)	/* informative message, not an error */
! 		    mch_msg((char *)buf);
! 		else
! 		    mch_errmsg((char *)buf);
  	    }
  
  	    /* primitive way to compute the current column */
***************
*** 1827,1834 ****
  #endif
  
  /*
!  * collect error messages until the GUI has started and they can be
!  * displayed in a message box.
   */
      void
  mch_errmsg(str)
--- 1830,1838 ----
  #endif
  
  /*
!  * Give an error message.  To be used when the screen hasn't been initialized
!  * yet.  When stderr can't be used, collect error messages until the GUI has
!  * started and they can be displayed in a message box.
   */
      void
  mch_errmsg(str)
***************
*** 1890,1895 ****
--- 1894,1904 ----
      }
  }
  
+ /*
+  * Give a message.  To be used when the screen hasn't been initialized yet.
+  * When there is no tty, collect messages until the GUI has started and they
+  * can be displayed in a message box.
+  */
      void
  mch_msg(str)
      char	*str;
*** ../vim60.231/src/version.c	Mon Feb 18 11:29:13 2002
--- src/version.c	Mon Feb 18 12:05:40 2002
***************
*** 608,609 ****
--- 608,611 ----
  {   /* Add new patch number below this line */
+ /**/
+     232,
  /**/

-- 
Mynd you, m00se bites Kan be pretty nasti ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
\\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
 \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///