Question about environment variables in vimscript

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about environment variables in vimscript

H Xu
  Hello everybody,

In vimscript, it is possible to modify the environment variables. My
question
is, how to execute a sh or batch file inside vimscript and the the
changes of
environment variables made by them take effect?

Thanks.

Regards,
Hong Xu
2010/10/2

--
You received this message from the "vim_use" 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
Reply | Threaded
Open this post in threaded view
|

Re: Question about environment variables in vimscript

Tom Link-3
> In vimscript, it is possible to modify the environment variables.

:let $foo = 1
:! echo $foo
1

I'd say you can set environment variables but this affects only
processes started by vim since the values of environment variables are
usually inherited from the caller.

Since Windows could be slightly different you might need to specify
more precisely which OS you use and what you're trying to achieve.

Regards,
Tom

--
You received this message from the "vim_use" 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
Reply | Threaded
Open this post in threaded view
|

Re: Question about environment variables in vimscript

Nikolay Aleksandrovich Pavlov
In reply to this post by H Xu
Ответ на сообщение «Question about environment variables in vimscript»,
присланное в 21:53:36 01 октября 2010, Пятница.
Отправитель: H Xu:

You can modify enviroment variables from vimscript using
    let $VARIABLE="value"
. You cannot export enviroment enviroment changes made by child process into
parent process neither in vimscript nor in other language: it is kernel level
restriction. If you see that something like
    function SetVar() {
        A="test"
    }
    A="test0"
    echo $A
    SetVar
    echo $A
echoes `test0' and then `test' it only means that `SetVar' function is executed
inside the same shell process. Parsing text that script outputs to stdout is the
only way to modify vim enviroment.

Текст сообщения:

>   Hello everybody,
>
> In vimscript, it is possible to modify the environment variables. My
> question
> is, how to execute a sh or batch file inside vimscript and the the
> changes of
> environment variables made by them take effect?
>
> Thanks.
>
> Regards,
> Hong Xu
> 2010/10/2

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Question about environment variables in vimscript

H Xu
  On 2010/10/2 2:31, ZyX wrote:

> Ответ на сообщение <<Question about environment variables in vimscript>>,
> присланное в 21:53:36 01 октября 2010, Пятница.
> Отправитель: H Xu:
>
> You can modify enviroment variables from vimscript using
>      let $VARIABLE="value"
> . You cannot export enviroment enviroment changes made by child process into
> parent process neither in vimscript nor in other language: it is kernel level
> restriction. If you see that something like
>      function SetVar() {
>          A="test"
>      }
>      A="test0"
>      echo $A
>      SetVar
>      echo $A
> echoes `test0' and then `test' it only means that `SetVar' function is executed
> inside the same shell process. Parsing text that script outputs to stdout is the
> only way to modify vim enviroment.
>
> Текст сообщения:
>>    Hello everybody,
>>
>> In vimscript, it is possible to modify the environment variables. My
>> question
>> is, how to execute a sh or batch file inside vimscript and the the
>> changes of
>> environment variables made by them take effect?
>>
>> Thanks.
>>
>> Regards,
>> Hong Xu
>> 2010/10/2

Hi ZyX:

I have understood. Thank you very much.

H Xu
2010/10/2

--
You received this message from the "vim_use" 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