Ben Fritz wrote:

> Fixed item from todo list:
> 
> > Win32: When 'shell' is cmd.exe this command fails:
> >     echo system('"c:/path/echo.exe" "foo bar"')
> > Should we set the default for 'shellxquote' to a double quote, when 'shell'
> > contains "cmd" in the tail?  (Benjamin Fritz, 2008 Oct 13)
> > Also set 'shellcmdflag' to include /s.
> 
> While making my changes, I noticed the following strange behavior.
> 
> If a user's .vimrc sets the value of 'shellxquote' or 'shellcmdflag',
> then the default value is not updated by the code I touched, because
> of the checks for the P_WAS_SET flag.
> 
> But this means, if the user has this in their .vimrc on Windows:
> 
> set shell=sh
> set shellxquote=\"
> set shellcmdflag=-c
> 
> Then a later command of :set shell& shellxquote& shellcmdflag& will
> set the values to "cmd.exe", "", and "/c" respectively. But if in
> their .vimrc they only have:
> 
> set shell=sh
> 
> then Vim automatically sets shellxquote and shellcmdflag to "\"" and
> "-c", respectively.
> 
> However, if the user later does :set shell& shellxquote&
> shellcmdflag&, they get "cmd.exe", "\"", and "-c".
> 
> More to the point for this patch, if the user has in their .vimrc on
> Windows, because they were enlightened back in 2008, 'set
> shellxquote=\" shellcmdflag=/s /c', then after this patch this is
> unnecessary, but if they try to set these values to their defaults,
> they will get the *old* defaults.
> 
> What is the reason for only updating the default value of options, if
> P_WAS_SET is false? I get that we don't want to override the actual
> value of the option if the user set it to something, but don't we want
> to update the default value? E.g. shouldn't we do something like this,
> throughout option.c?
> 
>       int     idx3;
> 
>       idx3 = findoption((char_u *)"shcf");
> -     if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
> -     {
> -         p_shcf = (char_u *)"-c";
> -         options[idx3].def_val[VI_DEFAULT] = p_shcf;
> +     if (idx3 >= 0)
> +     {
> +         options[idx3].def_val[VI_DEFAULT] = (char_u *)"-c";
> +         if (!(options[idx3].flags & P_WAS_SET))
> +         {
> +             p_shcf = options[idx3].def_val[VI_DEFAULT];
> +         }
>       }

When the user has set the option that we must not change it back to the
default.  When the user has changed the option, we should assume he
knows what he is doing and leave the value alone.

Only setting 'shcf' to the default would have to use the current value
of 'shell' to be right.  Not some stored value for an older value of
'shell'.  I don't think we have logic for that yet, would require some
refactoring to trigger the logic to fetch the default value when setting
an option to its default value.  Might be worth it though.

-- 
hundred-and-one symptoms of being an internet addict:
189. You put your e-mail address in the upper left-hand corner of envelopes.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui