2015-10-19 16:00 GMT+03:00 Karl (Xiangrong) Cai <xcai@juniper.net>:
> I thought this was pretty clear :-): And here are the steps again:
>
> 1) xterm with a login tcsh shell is created. At this time $c is set to /volume/current.
> 2) do " setenv c /volumeNew/current". As this time "echo $c" in this shell shows new value;
> 3) under vim, ":echo $c" shows new value;
> 4) under vim, ":let x = system("echo $c")", and then ":echo $c" shows old value.
These are again not all steps, as mentioned in the first reply. But in
any case, did you check what I asked in the very first message?
Because it looks like this question may be actually formulated as "*in
the same Vim instance* `echo $c` and `echo system('echo $c')` show
different $c value, why/how to synchronize them?" Basically this is
what I answered when writing
> You need to refer to your shell documentation. The answer to this
> question depends on which configuration files shell is sourcing in
> different cases. In case of system it is run using something like
> `&shell . ' ' .&shellcmdflag . ' ' . shellescape("echo $c")` (use
> `strace -e execve -f` to trace what is actually run).
>
> I think that system() is picking up your environment variable, but
> shell is overwriting it later with the "default" value sourced from
> configuration. To confirm revert to safer options (POSIX shell, which
> does not source tcsh configuration, and hopefully no its own: at least
> bash aliased to sh does not source any configuration with `sh -c 'echo
> true'` as confirmed by strace) and repeat:
>
> set shell=/bin/sh shellcmdflag=-c shellquote= shellxquote=
> echo system('echo $c')
>
> .
>
> --Karl
>
> -----Original Message-----
> From: vim_use@googlegroups.com [mailto:vim_use@googlegroups.com] On Behalf Of Nikolay Pavlov
> Sent: Monday, October 19, 2015 6:55 AM
> To: vim_use@googlegroups.com
> Subject: Re: system command takes a different environment variable from current shell?
>
> 2015-10-19 7:03 GMT+03:00 Karl (Xiangrong) Cai <xcai@juniper.net>:
>> Regarding " What is your _exact_ set of steps that results in echo $c showing /volumeNEW/current"
>>
>> 641% echo $c
>> /volume/current
>> 642% setenv c /volumeNew/current
>> 643% echo $c
>> /volumeNew/current
>>
>> My vim is version 7.4. But is has same problem on 7.3.121 or 7.0.94. And I tried this on FreeBSD and Linux. Thanks.
>> --Karl
>
> You said "in vim, when I do "echo $c" it shows the new value "/volumeNEW/current", but when I use the above mentioned 2nd way".
> "**In vim**", so these are *not* exact steps. And `643% echo $c` clearly suggests that you are doing this in shell.
>
> You need to show literally *everything* what you type to see the error, after the first shell was launched. E.g.
>
> setenv c /volumeNew/current
> vim
> :echo $c
> :echo system('echo $c')
>
>>
>> -----Original Message-----
>> From: vim_use@googlegroups.com [mailto:vim_use@googlegroups.com] On
>> Behalf Of Random832
>> Sent: Sunday, October 18, 2015 8:30 AM
>> To: vim_use@googlegroups.com
>> Subject: Re: system command takes a different environment variable from current shell?
>>
>> "Karl (Xiangrong) Cai" <xcai@juniper.net> writes:
>>> And in vim, when I do 1) echo $c, and 2) let x = system("echo $c");
>>> and then "echo x", both shows "/volume/current", which is expected;
>>> Then inside this shell I set this variable to another value:
>>> <<<
>>> 603% setenv c /volumeNEW/current
>>> 604% env | grep "SHELL\|current"
>>> SHELL=tcsh
>>> c=/volumeNEW/current
>>> XTERM_SHELL=/bin/tcsh
>>>>>>
>>> And now in in vim, when I do "echo $c" it shows the new value
>>> "/volumeNEW/current",
>>
>> That is very surprising, if you're not leaving anything out.
>>
>> How exactly did you set the variable? The only way to get back to the original shell without closing vim is to suspend vim (ctrl-z), but you didn't mention doing this. I suspended vim, did setenv, put vim back in foreground (fg), and echo $c showed the original value.
>>
>> What is your _exact_ set of steps that results in echo $c showing /volumeNEW/current ?
>>
>> --
>> --
>> 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
>>
>> ---
>> You received this message because you are subscribed to the Google Groups "vim_use" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> --
>> 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
>>
>> ---
>> You received this message because you are subscribed to the Google Groups "vim_use" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment