On Wed, Dec 7, 2016 at 8:55 PM, Gary Johnson <[email protected]> wrote: > On 2016-12-07, Christian Brabandt wrote: >> Hi Gary! >> >> On Mi, 07 Dez 2016, Gary Johnson wrote: >> >> > On 2016-09-28, Christian Brabandt wrote: >> > >> > > Let me just withdraw the patch. I use async feature now to workaround. >> > >> > I recently had a need to save and restore the value of v:shell_error >> > and went looking for this discussion. I had forgotten that you >> > withdrew the patch. FWIW, here's my workaround. This is from >> > a function that is called from a couple of autocommands. >> > >> > " Save current value of v:shell_error. >> > let l:shell_error = v:shell_error >> > >> > " Dummy example use of system() that also sets v:shell_error. >> > let stuff = system("do stuff") >> > >> > " Restore v:shell_error. >> > call system("exit ".l:shell_error) >> >> Yeah, that workaround was also suggested in the vim-airline issue >> tracker. But to be honest it's ugly to overwrite the exit value by >> shelling out again. > > Agreed. In fact, the actual code in my plugin says this: > > " Ugly hack to restore value of v:shell_error. > " > call system("exit ".l:shell_error) > > However, I'm not aware of a better solution.
To further emphasize the case against writable v:shell_error in particular: https://github.com/tpope/vim-fugitive/issues/648#issuecomment-282515016 Because the legacy "shell_error" variant (which lacks v: prefix) is still supported for "very important" reasons, if it were writable it could cause even more subtle bugs for plugin authors. Keeping it non-writable guards against those subtle bugs if a plugin author accidentally names a local variable "shell_error". And this happened to one of the most experienced "Vim script" authors in the world. --- Justin M. Keyes -- -- 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 --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
