Monday, October 19, 2015

RE: system command takes a different environment variable from current shell?

Great. Doing ":set shellcmdflag=-fc" under vim before doing the ":let x=..." solved the problem. Thanks!
--Karl

>-----Original Message-----
>From: vim_use@googlegroups.com [mailto:vim_use@googlegroups.com] On
>Behalf Of Nikolay Pavlov
>Sent: Monday, October 19, 2015 9:55 AM
>To: vim_use@googlegroups.com
>Subject: Re: system command takes a different environment variable from
>current shell?
>
>2015-10-19 16:49 GMT+03:00 Karl (Xiangrong) Cai <xcai@juniper.net>:
>>
>>
>>>-----Original Message-----
>>>From: vim_use@googlegroups.com [mailto:vim_use@googlegroups.com] On
>>>Behalf Of Random832
>>>Sent: Monday, October 19, 2015 9:14 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:
>>>
>>>> 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;
>>>
>>>Please provide _all_ the steps. According to these steps you haven't
>>>even started vim. And are you doing the setenv to volumeNew within
>>>your original shell (before starting vim?) or in a :! or system() call?
>>>
>>>Also, how is the old value set in the first place? Is it in your cshrc?
>>
>> [KCC] These are all the steps. First start the xterm and the tcsh, which as you
>said has $c set to old value in .cshrc. Then under the tcsh setenv $c to the new
>value. Then start vim and in vim do ":echo $c" which shows new value; and do
>":let x = system("echo $c")", and then ":echo x" shows old value.
>
>"Then start vim" was missing from the steps in your previous message.
>
>If you ignored all replies but the very first mine you would already have answer to
>your question: quick test shows that `tcsh -c` *does* source `~/.tcshrc`. So
>`system("echo $c")` is "internally" like `system('source ~/.tcshrc; echo $c')` which
>makes it obvious why $c has "incorrect" value.
>
>I have no `.cshrc`, but I do not think this makes a difference:
>documentation says this is a fallback for .tcshrc.
>
>You need to set &shellcmdflag to `-fc` to make tcsh not source its configuration.
>
>>
>>>> 4) under vim, ":let x = system("echo $c")", and then ":echo $c"
>>>> shows old value.
>>>
>>>Are you sure this is :echo $c or is it :echo x?
>> [KCC] My bad. It is ":echo x", which shows old value.
>> --Karl
>>
>> --
>> --
>> 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.

No comments:

Post a Comment