On Wednesday 22 July 2009 9:53 pm, Chris Sutcliffe wrote:
> 
> >> Is it possible to clear an environment variable via vim script?  I've 
> >> tried:
> >>
> >> let $MvVar =
> >>
> >> but vim complains.  I've also tried:
> >>
> >> unlet $MyVar
> >>
> >> with no success.
> >
> > did you define MyVar with a dollar sign?  or are you suffering from
> > iknowtoomanylanguagesitus?
> 
> It's an environmental variable that exists outside of Vim.  What I
> would like to do is clear it temporarily, call and external program,
> and restore it after calling the external program.  Something like:
> 
> let save_MyVar = $MyVar
> unlet $MyVar
> exe '!someprog'
> let $MyVar = save_MyVar
> 
> would be ideal, but the 'unlet' is the problem.

apparently i didn't have enough coffee this morning -- you did
indeed say it was an environment variable

since let and unlet are vim script commands, they affect variables
inside the script, not the environment

because '!' creates a new shell to run someprog, even if you
execute '!export MyVar=' your next '!someprog' is going to get yet
another shell to run in, and MyVar will be in its defined state

one of the oldest Laws of Unix is no script can modify its parent's
environment

my recommendation is to write a new shell script that undefines
MyVar and triggers someprog so vim doesn't have to care about shell
environment variables -- or tweak someprog so it doesn't use MyVar

sc


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to