Closed korsveien closed 9 years ago
Why the switch from system() to execute? Mostly concerned that this would change the cwd of the user's environment
Well, tested it out, seems to be working fine. Thanks for the patch! Still curious about the rationale, though. Probably something I don't know about Vim ;)
I can't give you a rationale because I more or less have none. I don't know much about vimscript, so this was basically the result after som googling. :-P
However I looked it up and it seems 'execute' simply performs an Ex-command with the string you provide it as a parameter. Apparently this is a common way of performing external commands in vimscript. It seems I could have just escaped the original string with shellescape() and keep using system(), but oh well. You learn something new everyday I guess.
If the path included special characters such as white space, the shell would return with an error message stating that cd received too many arguments. Also, an extra ':h' is added to the expand call in order to avoid having to resort to '..' in the middle of the pathname.