comparison src/option.c @ 3352:de050fcc24cf v7.3.443

updated for version 7.3.443 Problem: MS-Windows: 'shcf' and 'shellxquote' defaults are not very good. Solution: Make a better guess when 'shell' is set to "cmd.exe". (Ben Fritz)
author Bram Moolenaar <bram@vim.org>
date Sun, 12 Feb 2012 23:23:31 +0100
parents 076003f52582
children 397e7e49bb0b
comparison
equal deleted inserted replaced
3351:0da0c3c801cf 3352:de050fcc24cf
3881 } 3881 }
3882 #endif 3882 #endif
3883 3883
3884 #if defined(MSDOS) || defined(WIN3264) || defined(OS2) 3884 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3885 /* 3885 /*
3886 * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option. 3886 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3887 * 'shell' option.
3887 * This is done after other initializations, where 'shell' might have been 3888 * This is done after other initializations, where 'shell' might have been
3888 * set, but only if they have not been set before. Default for p_shcf is 3889 * set, but only if they have not been set before. Default for p_shcf is
3889 * "/c", for p_shq is "". For "sh" like shells it is changed here to 3890 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3890 * "-c" and "\"", but not for DJGPP, because it starts the shell without 3891 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3891 * command.com. And for Win32 we need to set p_sxq instead. 3892 * command.com. And for Win32 we need to set p_sxq instead.
3917 p_shq = (char_u *)"\""; 3918 p_shq = (char_u *)"\"";
3918 options[idx3].def_val[VI_DEFAULT] = p_shq; 3919 options[idx3].def_val[VI_DEFAULT] = p_shq;
3919 } 3920 }
3920 # endif 3921 # endif
3921 # endif 3922 # endif
3923 }
3924 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3925 {
3926 int idx3;
3927
3928 /*
3929 * cmd.exe on Windows will strip the first and last double quote given
3930 * on the command line, e.g. most of the time things like:
3931 * cmd /c "my path/to/echo" "my args to echo"
3932 * become:
3933 * my path/to/echo" "my args to echo
3934 * when executed.
3935 *
3936 * To avoid this, use the /s argument in addition to /c to force the
3937 * stripping behavior, and also set shellxquote to automatically
3938 * surround the entire command in quotes (which get stripped as
3939 * noted).
3940 */
3941
3942 /* Set shellxquote default to add the quotes to be stripped. */
3943 idx3 = findoption((char_u *)"sxq");
3944 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3945 {
3946 p_sxq = (char_u *)"\"";
3947 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3948 }
3949
3950 /* Set shellcmdflag default to always strip the quotes, note the order
3951 * between /s and /c is important or cmd.exe will treat the /s as part
3952 * of the command to be executed. */
3953 idx3 = findoption((char_u *)"shcf");
3954 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3955 {
3956 p_shcf = (char_u *)"/s /c";
3957 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3958 }
3922 } 3959 }
3923 #endif 3960 #endif
3924 3961
3925 #ifdef FEAT_TITLE 3962 #ifdef FEAT_TITLE
3926 set_title_defaults(); 3963 set_title_defaults();