comparison src/main.c @ 11666:5cd9ba96561d v8.0.0716

patch 8.0.0716: not easy to start Vim cleanly commit https://github.com/vim/vim/commit/c4da113ef98dcfd6f2a088b1693c0317dcb5bf42 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 15 19:39:43 2017 +0200 patch 8.0.0716: not easy to start Vim cleanly Problem: Not easy to start Vim cleanly without changing the viminfo file. Not possible to know whether the -i command line flag was used. Solution: Add the --clean command line argument. Add the 'viminfofile' option. Add "-u DEFAULTS".
author Christian Brabandt <cb@256bit.org>
date Sat, 15 Jul 2017 19:45:03 +0200
parents 42cd59477698
children 1ce1376fbbf8
comparison
equal deleted inserted replaced
11665:d7fe6dc88ea4 11666:5cd9ba96561d
431 vim_main2(void) 431 vim_main2(void)
432 { 432 {
433 #ifndef NO_VIM_MAIN 433 #ifndef NO_VIM_MAIN
434 /* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. 434 /* Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
435 * Allows for setting 'loadplugins' there. */ 435 * Allows for setting 'loadplugins' there. */
436 if (params.use_vimrc != NULL && STRCMP(params.use_vimrc, "NONE") == 0) 436 if (params.use_vimrc != NULL
437 && (STRCMP(params.use_vimrc, "NONE") == 0
438 || STRCMP(params.use_vimrc, "DEFAULTS") == 0))
437 p_lpl = FALSE; 439 p_lpl = FALSE;
438 440
439 /* Execute --cmd arguments. */ 441 /* Execute --cmd arguments. */
440 exe_pre_commands(&params); 442 exe_pre_commands(&params);
441 443
1867 break; 1869 break;
1868 1870
1869 case '-': /* "--" don't take any more option arguments */ 1871 case '-': /* "--" don't take any more option arguments */
1870 /* "--help" give help message */ 1872 /* "--help" give help message */
1871 /* "--version" give version message */ 1873 /* "--version" give version message */
1874 /* "--clean" clean context */
1872 /* "--literal" take files literally */ 1875 /* "--literal" take files literally */
1873 /* "--nofork" don't fork */ 1876 /* "--nofork" don't fork */
1874 /* "--not-a-term" don't warn for not a term */ 1877 /* "--not-a-term" don't warn for not a term */
1875 /* "--ttyfail" exit if not a term */ 1878 /* "--ttyfail" exit if not a term */
1876 /* "--noplugin[s]" skip plugins */ 1879 /* "--noplugin[s]" skip plugins */
1883 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ 1886 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
1884 list_version(); 1887 list_version();
1885 msg_putchar('\n'); 1888 msg_putchar('\n');
1886 msg_didout = FALSE; 1889 msg_didout = FALSE;
1887 mch_exit(0); 1890 mch_exit(0);
1891 }
1892 else if (STRNICMP(argv[0] + argv_idx, "clean", 5) == 0)
1893 {
1894 parmp->use_vimrc = (char_u *)"DEFAULTS";
1895 set_option_value((char_u *)"vif", 0L, (char_u *)"NONE", 0);
1888 } 1896 }
1889 else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) 1897 else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0)
1890 { 1898 {
1891 #ifdef EXPAND_FILENAMES 1899 #ifdef EXPAND_FILENAMES
1892 parmp->literal = TRUE; 1900 parmp->literal = TRUE;
2316 parmp->use_ef = (char_u *)argv[0]; 2324 parmp->use_ef = (char_u *)argv[0];
2317 break; 2325 break;
2318 #endif 2326 #endif
2319 2327
2320 case 'i': /* "-i {viminfo}" use for viminfo */ 2328 case 'i': /* "-i {viminfo}" use for viminfo */
2321 use_viminfo = (char_u *)argv[0]; 2329 set_option_value((char_u *)"vif", 0L, (char_u *)argv[0], 0);
2322 break; 2330 break;
2323 2331
2324 case 's': /* "-s {scriptin}" read from script file */ 2332 case 's': /* "-s {scriptin}" read from script file */
2325 if (scriptin[0] != NULL) 2333 if (scriptin[0] != NULL)
2326 { 2334 {
2986 * If -u argument given, use only the initializations from that file and 2994 * If -u argument given, use only the initializations from that file and
2987 * nothing else. 2995 * nothing else.
2988 */ 2996 */
2989 if (parmp->use_vimrc != NULL) 2997 if (parmp->use_vimrc != NULL)
2990 { 2998 {
2991 if (STRCMP(parmp->use_vimrc, "NONE") == 0 2999 if (STRCMP(parmp->use_vimrc, "DEFAULTS") == 0)
3000 do_source((char_u *)VIM_DEFAULTS_FILE, FALSE, DOSO_NONE);
3001 else if (STRCMP(parmp->use_vimrc, "NONE") == 0
2992 || STRCMP(parmp->use_vimrc, "NORC") == 0) 3002 || STRCMP(parmp->use_vimrc, "NORC") == 0)
2993 { 3003 {
2994 #ifdef FEAT_GUI 3004 #ifdef FEAT_GUI
2995 if (use_gvimrc == NULL) /* don't load gvimrc either */ 3005 if (use_gvimrc == NULL) /* don't load gvimrc either */
2996 use_gvimrc = parmp->use_vimrc; 3006 use_gvimrc = parmp->use_vimrc;
3381 main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>")); 3391 main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>"));
3382 #endif 3392 #endif
3383 #ifdef FEAT_VIMINFO 3393 #ifdef FEAT_VIMINFO
3384 main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo")); 3394 main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
3385 #endif 3395 #endif
3396 main_msg(_("--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo"));
3386 main_msg(_("-h or --help\tPrint Help (this message) and exit")); 3397 main_msg(_("-h or --help\tPrint Help (this message) and exit"));
3387 main_msg(_("--version\t\tPrint version information and exit")); 3398 main_msg(_("--version\t\tPrint version information and exit"));
3388 3399
3389 #ifdef FEAT_GUI_X11 3400 #ifdef FEAT_GUI_X11
3390 # ifdef FEAT_GUI_MOTIF 3401 # ifdef FEAT_GUI_MOTIF