On 2015-06-15, Paul wrote:
> I set the 'shell' option in my vimrc using:
>
> let &shell='/bin/bash -i'
>
> I've been trying to determine why I get a syntax error when my cursor
> is on a line bash command, e.g.,
>
> echo !(uIllinois*) matlab
>
> I should be able to issue one of the following 2 commands to either
> run the command in bash or filter the command through bash:
>
> :. w !bash
> !!bash
>
> The result is a syntax error where the round brackets are. It turns
> out that bash's extglob is unset, even though it is explicitly set
> from within ~/.bash_login, ~/.bashrc, and ~/.alias.bash (which is
> sourced from within the first 2 files).
I had the same problem a while back, but in my case I could verify
that my ~/.bashrc was _not_ being sourced when Vim executed bash.
> To track down the cause, I created the dummy text line
>
> shopt -p extglob
>
> and used diagnostic echo commands to ensure that the above 2
> invocations of bash actually execute ~/.bashrc and ~/.alias.bash (they
> do). For both bash invocations, extglob is unset.
Your observation that extglob is not set contradicts your claim that
~/.bashrc is being sourced. As you say later, it should not be.
How did you determine that ~/.bashrc is being sourced?
Having determined in my case that ~/.bashrc was not being sourced
when Vim invoked bash (except as :sh), and not really wanting it to
be sourced in that case because of the overhead, I found two
solutions.
One is to put the following in my ~/.vimrc:
set shellcmdflag=-O\ extglob\ -c
The other, 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.
HTH,
Gary
--
--
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.
Monday, June 15, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment