Monday, June 15, 2015

Re: extglob unset when filtering/writing text lines to bash

On Mon, Jun 15, 2015 at 9:55 PM, Paul <paul.domaskis@gmail.com> wrote:
> On Monday, June 15, 2015 at 9:11:12 PM UTC-4, Gary Johnson wrote:
>> The [solution] which I currently use...is to create a file,
>> ~/.vim/bash_env.sh, which contains the following:
>>
>> shopt -s extglob # Enable !(pattern-list).
>>
>> and then put this in my ~/.vimrc:
>>
>> if !exists("$BASH_ENV") || $BASH_ENV == ""
>> if filereadable($HOME . "/.vim/bash_env.sh")
>> let $BASH_ENV = "$HOME/.vim/bash_env.sh"
>> endif
>> endif
>>
>> The second seems more robust to me in part because I use the same
>> ~/.vimrc on a variety of machines and OSes and the first solution
>> doesn't work on Vims older that 7.3.269.
>
> I looked up BASH_ENV, and I see what you're doing. However, my
> vimrc (which is confirmed to run) explicitly does shopt -s extglob.
> In fact, I added an immediately subsequent shopt -p extglob, which
> confirms that extglob was successfully enabled. That's great when
> ~/.bashrc is running, but once that's done, it seems that it doesn't
> persist to the point where the code banged out from vim is run.
> Very, very weird.
>
> It's late, but I've got your example code above to try when I get a
> few extra moments. It's obvious that the shopt setting of extglob
> gets dropped sometime between completion of ~/.bashrc and execution
> of the code that is banged out from vim. BASH_ENV may solve the
> problem because it is persistent, and may get picked up by whatever
> bash process actually ends up running the banged out code.

Gary, your solution works fantastically. In order to avoid having to
provide separate bash_env.sh files for the PC and unix (cygwin)
versions of vim, I have one version of your vimrc code above for each
vim.

If the vimrc determine that the process is cygwin vim:

let &shell='/bin/bash -i'
if !exists("$BASH_ENV") || $BASH_ENV == ""
if filereadable($HOME . "/.vim/bash_env.sh")
let $BASH_ENV = "$HOME/.vim/bash_env.sh"
endif
endif

If the vimrc determine that the process is PC vim:

let cyghome='c:\cygwin64\home\'.$USERNAME
let &shell='set HOME='.cyghome.'& c:\cygwin64\bin\bash.exe -i'
if !exists("$BASH_ENV") || $BASH_ENV == ""
if filereadable(cyghome . '\.vim\bash_env.sh')
let $BASH_ENV = cyghome.'\.vim/bash_env.sh'
endif
endif

Thanks alot!

--
--
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