Monday, June 15, 2015

extglob unset when filtering/writing text lines to bash

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

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.

I realize that at least one contributing factor is that both
invocations of bash do not have the -i switch, and that the 'shell'
might be irrelevant here. I'd rather not pursue that path if possible
because if I do explicitly specify -i in the above invocations, I get
a dozen messages that I should use "exit" to leave shell.

I'd rather have a quicker fix. Specifically, since the above
invocations show that .bashrc and .alias.bash are executed, why is
extglob unset, and how can I make its activation persistent? I admit
that I do not know *why* .bashrc and .alias.bash are being sourced,
and as far as I can see they shouldn't be. However, since they are
being run, I'm hoping that there is a way to make the extglob setting
stick.

I'm using gvim with the following version info (updating is difficult
in my particular work environment):

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 19 2014 10:14:40)
Included patches: 1-182
Compiled by <cygwin-xfree_AT_cygwin.com>
Huge version with GTK2 GUI. Features included (+) or not (-):

+acl +comments +ex_extra +jumplist
+arabic +conceal +extra_search +keymap
+autocmd +cryptv +farsi +langmap
+balloon_eval +cscope +file_in_path +libcall
+browse +cursorbind +find_in_path +linebreak
++builtin_terms +cursorshape +float +lispindent
+byte_offset +dialog_con_gui +folding +listcmds
+cindent +diff -footer +localmap
+clientserver +digraphs +fork() +lua/dyn
+clipboard +dnd +gettext +menu
+cmdline_compl -ebcdic -hangul_input +mksession
+cmdline_hist +emacs_tags +iconv +modify_fname
+cmdline_info +eval +insert_expand +mouse

+mouseshape +path_extra +signs +textobjects
+mouse_dec +perl/dyn +smartindent +title
-mouse_gpm +persistent_undo -sniff +toolbar
-mouse_jsbterm +postscript +startuptime +user_commands
+mouse_netterm +printer +statusline +vertsplit
+mouse_sgr +profile -sun_workshop +virtualedit
-mouse_sysmouse +python/dyn +syntax +visual
+mouse_urxvt +python3/dyn +tag_binary +visualextra
+mouse_xterm +quickfix +tag_old_static +viminfo
+multi_byte +reltime -tag_any_white +vreplace
+multi_lang +rightleft -tcl +wildignore
-mzscheme +ruby/dyn +terminfo +wildmenu
+netbeans_intg +scrollbind +termresponse +windows

+writebackup
+X11
-xfontset
+xim
+xsmp_interact
+xterm_clipboard
-xterm_save
+xpm

system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/harfbuzz -I/usr/include/ncursesw -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/ports/vim/vim-7.4.182-1.x86_64/build=/usr/src/debug/vim-7.4.182-1 -fdebug-prefix-map=/usr/src/ports/vim/vim-7.4.182-1.x86_64/src/vim74=/usr/src/debug/vim-7.4.182-1 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -L/usr/local/lib -Wl,--as-needed -o vim.exe -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangocairo-1.0 -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage -lgdk_pixbuf-2.0 -lpangoft2-1.0 -lgio-2.0 -lXfixes -lcairo -lpixman-1 -lxcb-shm -lxcb-render -lXrender -lXext -lX11 -lxcb -lXau -lXdmcp -lpng15 -lharfbuzz -lpango-1.0 -lm -lfontconfig -lexpat -lfreetype -lz -lbz2 -lgmodule-2.0 -lgobject-2.0 -lffi -lglib-2.0 -lintl -liconv -lpcre -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -lelf -lncursesw -liconv -lintl -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector -L/usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE -lperl -ldl -lcrypt

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