comparison src/option.c @ 13162:51521b8a370c v8.0.1455

patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect commit https://github.com/vim/vim/commit/4bfa8af14142e54f509048239f4e8596911f56aa Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 3 15:14:46 2018 +0100 patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect Problem: If $SHELL contains a space then the default value of 'shell' is incorrect. (Matthew Horan) Solution: Escape spaces in $SHELL. (Christian Brabandt, closes #459)
author Christian Brabandt <cb@256bit.org>
date Sat, 03 Feb 2018 15:15:05 +0100
parents 53cc7ea77c54
children 6e972d830e13
comparison
equal deleted inserted replaced
13161:12a782ea6e51 13162:51521b8a370c
3263 static char *(p_scl_values[]) = {"yes", "no", "auto", NULL}; 3263 static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3264 #endif 3264 #endif
3265 3265
3266 static void set_option_default(int, int opt_flags, int compatible); 3266 static void set_option_default(int, int opt_flags, int compatible);
3267 static void set_options_default(int opt_flags); 3267 static void set_options_default(int opt_flags);
3268 static void set_string_default_esc(char *name, char_u *val, int escape);
3268 static char_u *term_bg_default(void); 3269 static char_u *term_bg_default(void);
3269 static void did_set_option(int opt_idx, int opt_flags, int new_value); 3270 static void did_set_option(int opt_idx, int opt_flags, int new_value);
3270 static char_u *illegal_char(char_u *, int); 3271 static char_u *illegal_char(char_u *, int);
3271 #ifdef FEAT_CMDWIN 3272 #ifdef FEAT_CMDWIN
3272 static char_u *check_cedit(void); 3273 static char_u *check_cedit(void);
3369 # ifdef WIN3264 3370 # ifdef WIN3264
3370 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) 3371 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
3371 # endif 3372 # endif
3372 #endif 3373 #endif
3373 ) 3374 )
3374 set_string_default("sh", p); 3375 set_string_default_esc("sh", p, TRUE);
3375 3376
3376 #ifdef FEAT_WILDIGN 3377 #ifdef FEAT_WILDIGN
3377 /* 3378 /*
3378 * Set the default for 'backupskip' to include environment variables for 3379 * Set the default for 'backupskip' to include environment variables for
3379 * temp files. 3380 * temp files.
3857 } 3858 }
3858 3859
3859 /* 3860 /*
3860 * Set the Vi-default value of a string option. 3861 * Set the Vi-default value of a string option.
3861 * Used for 'sh', 'backupskip' and 'term'. 3862 * Used for 'sh', 'backupskip' and 'term'.
3863 * When "escape" is TRUE escape spaces with a backslash.
3862 */ 3864 */
3863 void 3865 static void
3864 set_string_default(char *name, char_u *val) 3866 set_string_default_esc(char *name, char_u *val, int escape)
3865 { 3867 {
3866 char_u *p; 3868 char_u *p;
3867 int opt_idx; 3869 int opt_idx;
3868 3870
3869 p = vim_strsave(val); 3871 if (escape && vim_strchr(val, ' ') != NULL)
3872 p = vim_strsave_escaped(val, (char_u *)" ");
3873 else
3874 p = vim_strsave(val);
3870 if (p != NULL) /* we don't want a NULL */ 3875 if (p != NULL) /* we don't want a NULL */
3871 { 3876 {
3872 opt_idx = findoption((char_u *)name); 3877 opt_idx = findoption((char_u *)name);
3873 if (opt_idx >= 0) 3878 if (opt_idx >= 0)
3874 { 3879 {
3876 vim_free(options[opt_idx].def_val[VI_DEFAULT]); 3881 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3877 options[opt_idx].def_val[VI_DEFAULT] = p; 3882 options[opt_idx].def_val[VI_DEFAULT] = p;
3878 options[opt_idx].flags |= P_DEF_ALLOCED; 3883 options[opt_idx].flags |= P_DEF_ALLOCED;
3879 } 3884 }
3880 } 3885 }
3886 }
3887
3888 void
3889 set_string_default(char *name, char_u *val)
3890 {
3891 set_string_default_esc(name, val, FALSE);
3881 } 3892 }
3882 3893
3883 /* 3894 /*
3884 * Set the Vi-default value of a number option. 3895 * Set the Vi-default value of a number option.
3885 * Used for 'lines' and 'columns'. 3896 * Used for 'lines' and 'columns'.