@@ -973,7 +973,7 @@ common_init(mparm_T *paramp)
973973 * (needed for :! to * work). mch_check_win() will also handle the -d or
974974 * -dev argument.
975975 */
976- paramp -> stdout_isatty = (mch_check_win (paramp -> argc , paramp -> argv ) != FAIL );
976+ stdout_isatty = (mch_check_win (paramp -> argc , paramp -> argv ) != FAIL );
977977 TIME_MSG ("window checked" );
978978
979979 /*
@@ -1828,6 +1828,7 @@ command_line_scan(mparm_T *parmp)
18281828 /* "--literal" take files literally */
18291829 /* "--nofork" don't fork */
18301830 /* "--not-a-term" don't warn for not a term */
1831+ /* "--ttyfail" exit if not a term */
18311832 /* "--noplugin[s]" skip plugins */
18321833 /* "--cmd <cmd>" execute cmd before vimrc */
18331834 if (STRICMP (argv [0 ] + argv_idx , "help" ) == 0 )
@@ -1857,6 +1858,8 @@ command_line_scan(mparm_T *parmp)
18571858 p_lpl = FALSE;
18581859 else if (STRNICMP (argv [0 ] + argv_idx , "not-a-term" , 10 ) == 0 )
18591860 parmp -> not_a_term = TRUE;
1861+ else if (STRNICMP (argv [0 ] + argv_idx , "ttyfail" , 7 ) == 0 )
1862+ parmp -> tty_fail = TRUE;
18601863 else if (STRNICMP (argv [0 ] + argv_idx , "cmd" , 3 ) == 0 )
18611864 {
18621865 want_argument = TRUE;
@@ -2489,7 +2492,7 @@ check_tty(mparm_T *parmp)
24892492 if (!input_isatty )
24902493 silent_mode = TRUE;
24912494 }
2492- else if (parmp -> want_full_screen && (!parmp -> stdout_isatty || !input_isatty )
2495+ else if (parmp -> want_full_screen && (!stdout_isatty || !input_isatty )
24932496#ifdef FEAT_GUI
24942497 /* don't want the delay when started from the desktop */
24952498 && !gui .starting
@@ -2504,7 +2507,7 @@ check_tty(mparm_T *parmp)
25042507 * input buffer so fast I can't even kill the process in under 2
25052508 * minutes (and it beeps continuously the whole time :-)
25062509 */
2507- if (netbeans_active () && (!parmp -> stdout_isatty || !input_isatty ))
2510+ if (netbeans_active () && (!stdout_isatty || !input_isatty ))
25082511 {
25092512 mch_errmsg (_ ("Vim: Error: Failure to start gvim from NetBeans\n" ));
25102513 exit (1 );
@@ -2517,11 +2520,13 @@ check_tty(mparm_T *parmp)
25172520 exit (1 );
25182521 }
25192522#endif
2520- if (!parmp -> stdout_isatty )
2523+ if (!stdout_isatty )
25212524 mch_errmsg (_ ("Vim: Warning: Output is not to a terminal\n" ));
25222525 if (!input_isatty )
25232526 mch_errmsg (_ ("Vim: Warning: Input is not from a terminal\n" ));
25242527 out_flush ();
2528+ if (parmp -> tty_fail && (!stdout_isatty || !input_isatty ))
2529+ exit (1 );
25252530 if (scriptin [0 ] == NULL )
25262531 ui_delay (2000L , TRUE);
25272532 TIME_MSG ("Warning delay" );
@@ -3287,6 +3292,7 @@ usage(void)
32873292#endif
32883293 main_msg (_ ("-T <terminal>\tSet terminal type to <terminal>" ));
32893294 main_msg (_ ("--not-a-term\t\tSkip warning for input/output not being a terminal" ));
3295+ main_msg (_ ("--ttyfail\t\tExit if input or output is not a terminal" ));
32903296 main_msg (_ ("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc" ));
32913297#ifdef FEAT_GUI
32923298 main_msg (_ ("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc" ));
0 commit comments