Mercurial > vim
comparison src/main.c @ 10404:65e0537a4560 v8.0.0096
commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 24 15:09:07 2016 +0100
patch 8.0.0096
Problem: When the input or output is not a tty Vim appears to hang.
Solution: Add the --ttyfail argument. Also add the "ttyin" and "ttyout"
features to be able to check in Vim script.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 24 Nov 2016 15:15:04 +0100 |
parents | 4aead6a9b7a9 |
children | cd179d7d0b5d |
comparison
equal
deleted
inserted
replaced
10403:491b6a166e42 | 10404:65e0537a4560 |
---|---|
971 * Check if we have an interactive window. | 971 * Check if we have an interactive window. |
972 * On the Amiga: If there is no window, we open one with a newcli command | 972 * On the Amiga: If there is no window, we open one with a newcli command |
973 * (needed for :! to * work). mch_check_win() will also handle the -d or | 973 * (needed for :! to * work). mch_check_win() will also handle the -d or |
974 * -dev argument. | 974 * -dev argument. |
975 */ | 975 */ |
976 paramp->stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); | 976 stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); |
977 TIME_MSG("window checked"); | 977 TIME_MSG("window checked"); |
978 | 978 |
979 /* | 979 /* |
980 * Allocate the first window and buffer. | 980 * Allocate the first window and buffer. |
981 * Can't do anything without it, exit when it fails. | 981 * Can't do anything without it, exit when it fails. |
1826 /* "--help" give help message */ | 1826 /* "--help" give help message */ |
1827 /* "--version" give version message */ | 1827 /* "--version" give version message */ |
1828 /* "--literal" take files literally */ | 1828 /* "--literal" take files literally */ |
1829 /* "--nofork" don't fork */ | 1829 /* "--nofork" don't fork */ |
1830 /* "--not-a-term" don't warn for not a term */ | 1830 /* "--not-a-term" don't warn for not a term */ |
1831 /* "--ttyfail" exit if not a term */ | |
1831 /* "--noplugin[s]" skip plugins */ | 1832 /* "--noplugin[s]" skip plugins */ |
1832 /* "--cmd <cmd>" execute cmd before vimrc */ | 1833 /* "--cmd <cmd>" execute cmd before vimrc */ |
1833 if (STRICMP(argv[0] + argv_idx, "help") == 0) | 1834 if (STRICMP(argv[0] + argv_idx, "help") == 0) |
1834 usage(); | 1835 usage(); |
1835 else if (STRICMP(argv[0] + argv_idx, "version") == 0) | 1836 else if (STRICMP(argv[0] + argv_idx, "version") == 0) |
1855 } | 1856 } |
1856 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) | 1857 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) |
1857 p_lpl = FALSE; | 1858 p_lpl = FALSE; |
1858 else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) | 1859 else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) |
1859 parmp->not_a_term = TRUE; | 1860 parmp->not_a_term = TRUE; |
1861 else if (STRNICMP(argv[0] + argv_idx, "ttyfail", 7) == 0) | |
1862 parmp->tty_fail = TRUE; | |
1860 else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) | 1863 else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) |
1861 { | 1864 { |
1862 want_argument = TRUE; | 1865 want_argument = TRUE; |
1863 argv_idx += 3; | 1866 argv_idx += 3; |
1864 } | 1867 } |
2487 if (exmode_active) | 2490 if (exmode_active) |
2488 { | 2491 { |
2489 if (!input_isatty) | 2492 if (!input_isatty) |
2490 silent_mode = TRUE; | 2493 silent_mode = TRUE; |
2491 } | 2494 } |
2492 else if (parmp->want_full_screen && (!parmp->stdout_isatty || !input_isatty) | 2495 else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) |
2493 #ifdef FEAT_GUI | 2496 #ifdef FEAT_GUI |
2494 /* don't want the delay when started from the desktop */ | 2497 /* don't want the delay when started from the desktop */ |
2495 && !gui.starting | 2498 && !gui.starting |
2496 #endif | 2499 #endif |
2497 && !parmp->not_a_term) | 2500 && !parmp->not_a_term) |
2502 * output coming to the console and XOpenDisplay fails, I get vim | 2505 * output coming to the console and XOpenDisplay fails, I get vim |
2503 * trying to start with input/output to my console tty. This fills my | 2506 * trying to start with input/output to my console tty. This fills my |
2504 * input buffer so fast I can't even kill the process in under 2 | 2507 * input buffer so fast I can't even kill the process in under 2 |
2505 * minutes (and it beeps continuously the whole time :-) | 2508 * minutes (and it beeps continuously the whole time :-) |
2506 */ | 2509 */ |
2507 if (netbeans_active() && (!parmp->stdout_isatty || !input_isatty)) | 2510 if (netbeans_active() && (!stdout_isatty || !input_isatty)) |
2508 { | 2511 { |
2509 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); | 2512 mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); |
2510 exit(1); | 2513 exit(1); |
2511 } | 2514 } |
2512 #endif | 2515 #endif |
2515 { | 2518 { |
2516 mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n")); | 2519 mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n")); |
2517 exit(1); | 2520 exit(1); |
2518 } | 2521 } |
2519 #endif | 2522 #endif |
2520 if (!parmp->stdout_isatty) | 2523 if (!stdout_isatty) |
2521 mch_errmsg(_("Vim: Warning: Output is not to a terminal\n")); | 2524 mch_errmsg(_("Vim: Warning: Output is not to a terminal\n")); |
2522 if (!input_isatty) | 2525 if (!input_isatty) |
2523 mch_errmsg(_("Vim: Warning: Input is not from a terminal\n")); | 2526 mch_errmsg(_("Vim: Warning: Input is not from a terminal\n")); |
2524 out_flush(); | 2527 out_flush(); |
2528 if (parmp->tty_fail && (!stdout_isatty || !input_isatty)) | |
2529 exit(1); | |
2525 if (scriptin[0] == NULL) | 2530 if (scriptin[0] == NULL) |
2526 ui_delay(2000L, TRUE); | 2531 ui_delay(2000L, TRUE); |
2527 TIME_MSG("Warning delay"); | 2532 TIME_MSG("Warning delay"); |
2528 } | 2533 } |
2529 } | 2534 } |
3285 #ifdef FEAT_FKMAP | 3290 #ifdef FEAT_FKMAP |
3286 main_msg(_("-F\t\t\tStart in Farsi mode")); | 3291 main_msg(_("-F\t\t\tStart in Farsi mode")); |
3287 #endif | 3292 #endif |
3288 main_msg(_("-T <terminal>\tSet terminal type to <terminal>")); | 3293 main_msg(_("-T <terminal>\tSet terminal type to <terminal>")); |
3289 main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal")); | 3294 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")); | |
3290 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc")); | 3296 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc")); |
3291 #ifdef FEAT_GUI | 3297 #ifdef FEAT_GUI |
3292 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc")); | 3298 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc")); |
3293 #endif | 3299 #endif |
3294 main_msg(_("--noplugin\t\tDon't load plugin scripts")); | 3300 main_msg(_("--noplugin\t\tDon't load plugin scripts")); |