Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 277891 - www-client/surfraw-2.2.5 bash_completion syntax error
Summary: www-client/surfraw-2.2.5 bash_completion syntax error
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: James Rowe
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-15 06:19 UTC by urcindalo
Modified: 2009-07-27 16:15 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
surfraw-fix_standalone_completion.patch (surfraw-fix_standalone_completion.patch,1011 bytes, patch)
2009-07-24 17:26 UTC, James Rowe
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description urcindalo 2009-07-15 06:19:45 UTC
Hi! I just installed surfraw-2.2.5 on a mostly stable AMD64, enabled bashcomp for my user, and got this error everytime I open a new terminal session:

===
bash: /home/ramiro/.bash_completion.d/surfraw: line 32: syntax error in conditional expression: unexpected token `('
bash: /home/ramiro/.bash_completion.d/surfraw: line 32: syntax error near `@(a'
bash: /home/ramiro/.bash_completion.d/surfraw: line 32: `       elif    [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]]'
===

So, something's wrong with /usr/share/bash-completion/surfraw at line 32.

Reproducible: Always




Portage 2.1.6.13 (default/linux/amd64/2008.0/desktop, gcc-4.3.2, glibc-2.9_p20081201-r2, 2.6.29-gentoo-r5 x86_64)
=================================================================
System uname: Linux-2.6.29-gentoo-r5-x86_64-AMD_Athlon-tm-_64_Processor_3000+-with-glibc2.2.5
Timestamp of tree: Tue, 14 Jul 2009 10:30:01 +0000
app-shells/bash:     3.2_p39
dev-java/java-config: 2.1.8-r1
dev-lang/python:     2.5.4-r3
dev-util/cmake:      2.6.4
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.13, 2.63
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -mtune=athlon64 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-march=athlon64 -mtune=athlon64 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo-euetib.upc.es/mirror/gentoo/ "
LANG="es_ES.utf8"
LC_ALL="es_ES.utf8"
LDFLAGS="-Wl,-O1"
LINGUAS="es_ES es en_US en"
MAKEOPTS="-j2"
PKGDIR="/home/ramiro/usr/local/portage/pkgdir-backup/"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/layman/roslin /usr/portage/local/layman/science /usr/portage/local/layman/sunrise /usr/portage/local/personal /usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext 7zip X X509 a52 aac aalib abiword accessibility acl acpi additions adns alsa amd64 aotuv apbs apm archive ass audiofile auth authfile autoreplace avahi bash-completion bcmath bdf beagle berkdb binary-drivers binfilter blas bonjour branding bzip2 cairo caps cdda cddax cddb cdparanoia cdr cdrom chm chroot clamav cli connectionstatus contactnotes context corefonts cracklib crypt css ctype cups cupsddk curl curlwrappers custom-optimization dbus dbx detex dga dia directfb disk-partition diskio divx djvu dri dvb dvd dvdr dvdread dvi dvipdfm eds emboss emovix enca encode erandom esd evo exif extensions extra fam fame fastcgi fat fbcon ffmpeg fftw firefox flac flatfile fontconfig foomaticdb fortran fpx ftp fuse gd gdbm geoip geolocation gif gimp ginac glibc-omitfp glitz glsl glut gmp gnome gnuplot gnutls google gphoto2 gpm grammar graphics graphviz grub gs gsl gstreamer gtk gzip hal hddtemp hdri hfs history hpn humanities iconv icu id3tag idn ieee1394 imagemagick imap imlib immqt-bc inifile inkjar innodb ipv6 isdnlog jack jadetex java java6 javascript jbig jce jfs jpeg jpeg2k justify kde kipi ladspa lame latex latex3 lcms ldap libcaca libdsk libgda libnotify libssh2 libwww live lm_sensors logitech-mouse logrotate loop-aes lua lzo m17n-lib mad maildir mailwrapper math matroska mbox mcve md5sum mdb memlimit midi mikmod milter mime mjpeg mmap mmx mmxext mng modplug mono motif mozilla moznoirc moznomail mp3 mpeg mpeg2 mpi mplayer msn mudflap multilib multiuser musepack music musicbrainz nas ncurses neXt net netboot network network-cron networking networkmanager new-login nfs nis nls npp nptl nptlonly nsplugin ntfs nvidia octave ofx ogg ole omega openal openbabel openexr opengl openmp openssl opensslcrypt openvpn osc ots pam pango parse-clocks pcntl pcre pdf perl plotutils plugins png portaudio posix postgres postproc postscript povray ppds pppd profile ps pstricks publishers pymol python qt3 qt3support qt4 quicktime rar raw rdesktop readline realmedia reflection reiser4 reiserfs replytolist resolvconf rtc rtf rtsp ruby samba sasl savedconfig scanner science screenshot sdk sdl sdl-image sensord session shout sift simplexml skey skins slang slp sndfile snmp soap sockets socks5 solver source sox speex spell spl sse sse2 ssl startup-notification subtitles subversion svg svgz swat sysfs syslog sysvipc szip t1lib taglib tcl tcpd teletext tex4ht tga theora thesaurus thunderbird tidy tiff tk truetype twolame unicode usb userlocales v4l v4l2 vcd vcdx vlm vnc vorbis wavpack wddx webdav winbind winpopup wmf wmp wxwindows x264 xanim xattr xcb xcomposite xetex xface xfce xforms xfs xft xindy xine xml xmlreader xmlrpc xmlwriter xorg xorgmodule xplanet xpm xscreensaver xsl xulrunner xv xvid xvmc yv12 zeroconf zip zlib zoran" ALSA_CARDS="via82xx" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" CAMERAS="fuji minolta ptp2 ptp" ELIBC="glibc" FOO2ZJS_DEVICES="hp1000" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="es_ES es en_US en" SANE_BACKENDS="epson2 hp" USERLAND="GNU" VIDEO_CARDS="nv nvidia vesa fbdev"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 James Rowe 2009-07-15 23:10:25 UTC
  That is definitely an odd error, it looks like somehow bash's extglob
option has become unset.  It is explicitly set by the .pre script
because the whole of the bash completion package makes extensive use of
it, so this shouldn't be happening.

  Are you sure you've not unset it yourself for some other reason?
I can't duplicate this error myself without manually breaking my
environment.

  I guess one "solution" could be to forcibly set extglob in the
completion script, but it is worth noting that this is not normally
needed and none of the other extglob dependant scripts do this.  I'd
much rather figure out what is actually causing this than just tacking
on a 'shopt -s extglob'.

Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2009-07-22 18:02:48 UTC
As requested by James, please reopen this bug when you provide the output of the following command:

  grep shopt ~/.bash* /etc/bash/* /etc/profile /etc/profile.d/
Comment 3 James Rowe 2009-07-22 18:11:35 UTC
urcindalo, also the output of
"grep shopt.*extglob /usr/share/bash-completion/*" may be helpful, in case 
there is a completion script from a package I've not found that is causing this.
Comment 4 urcindalo 2009-07-23 09:59:18 UTC
OK. Here they are:

==========
~ $ grep shopt ~/.bash* /etc/bash/* /etc/profile /etc/profile.d/
/etc/bash/bashrc:shopt -s checkwinsize
/etc/bash/bashrc:shopt -s histappend
~ $ grep shopt.*extglob /usr/share/bash-completion/*
/usr/share/bash-completion/subversion:# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
/usr/share/bash-completion/subversion:shopt -s extglob
~ $ eix -I subversion
[I] dev-util/subversion
     Available versions:  ~1.4.6-r2!t[1] 1.5.5!t 1.5.6!t ~1.6.1!t 1.6.2 ~1.6.2-r10 ~1.6.3 ~1.6.3-r10 {apache2 bash-completion berkdb ctypes-python debug doc dso elibc_FreeBSD emacs extras gnome-keyring java kde nls nowebdav perl python ruby sasl svnserve test vim-syntax webdav-neon webdav-serf}
     Installed versions:  1.6.2(11:21:03 29/06/09)(bash-completion berkdb java nls perl python ruby sasl webdav-neon -apache2 -ctypes-python -debug -doc -dso -elibc_FreeBSD -emacs -extras -gnome-keyring -test -vim-syntax -webdav-serf)
     Homepage:            http://subversion.tigris.org/
     Description:         Advanced version control system

[1] (layman/ecatmur)
~ $
=========

I've added my subversion version because of the output of the second grep command.

Hope this helps. Also, if it is of any value, I understood nothing in comment #2... :oops: :-D

Thanks in advance.
Comment 5 urcindalo 2009-07-23 09:59:56 UTC
Requested info provided.
Comment 6 James Rowe 2009-07-23 14:32:42 UTC
  Thanks for the updated information.

(In reply to comment #4)
> Also, if it is of any value, I understood nothing in comment
> #2... :oops: :-D

  I take it you meant my explanation which was actually comment #1? That's 
okay, let me try to explain a little better :)

  The syntax used in the surfraw completion script is in fact valid bash
syntax, it just depends on bash's extglob option being turned on.
extglob provides bash with extended pattern matching abilities, which is
what the @(...|...) syntax is.  As the bash-completion package makes
extensive use of that feature it is forced on in
/usr/share/bash-completion/.pre , you can see for yourself just how
often it is used by "grep '@(' /usr/share/bash-completion/*".

  The only reason I'm know of that could cause you to see that error is
if somehow the option has been disabled, I was asking whether you had
done that for some other reason.  That is also why I wanted to see your
bash configs.  Unfortunately, even with your extra information I still
can't see what is causing it yet, so thanks for your patience.

  In the meantime the quick workaround would be to place "shopt -s
extglob" at the top of the surfraw completion script.

  Could you please post the output of "grep shopt /etc/profile.d/*".
There was a missing * in the comment above, which was entirely my fault.
And the output of "shopt" in any shell that is exhibiting this bug may also
be helpful.

Thanks
Comment 7 urcindalo 2009-07-24 06:29:58 UTC
>   I take it you meant my explanation which was actually comment #1? That's 
> okay, let me try to explain a little better :)

Thanks. Yes, I meant #1. I took for granted if mine was #1 yours was #2... .-D

> ...you can see for yourself just how
> often it is used by "grep '@(' /usr/share/bash-completion/*".

OK. I even show you the output. Only subversion and surfraw make use of it:

=====
~ $ grep '@(' /usr/share/bash-completion/*
/usr/share/bash-completion/subversion:  if [[ $opt == @(dir|all) && -d "$f" ]] ; then
/usr/share/bash-completion/subversion:  elif [[ $opt == @(file|all) ]] ; then
/usr/share/bash-completion/subversion:      if [[ $prev == @($optsParam) ]] ; then
/usr/share/bash-completion/subversion:      if [[ $prev == @(<|>|>>|[12]>|[12]>>) ]] ; then
/usr/share/bash-completion/subversion:               && ( $opt != -* || $opt == @(${specOpts// /|}) ) ]]
/usr/share/bash-completion/subversion:          [[ $cmd == @($propCmds) ]] && isPropCmd=1
/usr/share/bash-completion/subversion:          [[ $cmd == @($psCmds) ]] && isPsCmd=1
/usr/share/bash-completion/subversion:          [[ $cmd == @(${helpOpts// /|}) ]] && cmd='help'
/usr/share/bash-completion/subversion:          [[ $prop == @(${revProps// /|}) ]] && isRevProp=1
/usr/share/bash-completion/subversion:              if [[ $c == $cur* && ( ! $seen || $c != @($seen) ) ]]
/usr/share/bash-completion/subversion:                  files=$($status $cs| _svn_grcut '@([MADR!]*| M*|_M*)')
/usr/share/bash-completion/subversion:                  files=$($status $cs| _svn_grcut '@(??L*|?????[KOTB]*)')
/usr/share/bash-completion/subversion:                  files=$($status $cs| _svn_grcut '@(?C*|C*)')
/usr/share/bash-completion/subversion:                  if [[ $cmd == @($propCmds) && \
/usr/share/bash-completion/subversion:                        $prop == @(svn:ignore|svn:externals) ]] ; then
/usr/share/bash-completion/subversion:  if [[ $acceptOpt == @(edit|launch) ]] ;
/usr/share/bash-completion/subversion:complete -F _svn -o default -X '@(*/.svn|*/.svn/|.svn|.svn/)' svn
/usr/share/bash-completion/subversion:  if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \
/usr/share/bash-completion/subversion:     [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then
/usr/share/bash-completion/subversion:          if [[ $opt == @($optsParam) ]] ; then
/usr/share/bash-completion/subversion:  if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \
/usr/share/bash-completion/subversion:     [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then
/usr/share/bash-completion/subversion:          if [[ $opt == @($optsParam) ]] ; then
/usr/share/bash-completion/surfraw:     elif    [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]]
~ $
===== 

>   Could you please post the output of "grep shopt /etc/profile.d/*".

Sure. It shows nothing. I don't know if that's correct or not.

=====
~ $ grep shopt /etc/profile.d/*
~ $
=====

> And the output of "shopt" in any shell that is exhibiting this bug may also
> be helpful.

I run an almost stable AMD64 box and my shell is just bash:

=====
~ $ shopt
cdable_vars     off
cdspell         off
checkhash       off
checkwinsize    on
cmdhist         on
compat31        off
dotglob         off
execfail        off
expand_aliases  on
extdebug        off
extglob         off
extquote        on
failglob        off
force_fignore   on
gnu_errfmt      off
histappend      on
histreedit      off
histverify      off
hostcomplete    on
huponexit       off
interactive_comments    on
lithist         off
login_shell     off
mailwarn        off
no_empty_cmd_completion off
nocaseglob      off
nocasematch     off
nullglob        off
progcomp        on
promptvars      on
restricted_shell        off
shift_verbose   off
sourcepath      on
xpg_echo        off
~ $ eix -I bash
[I] app-shells/bash
     Available versions:  3.1_p17 3.2_p39 ~3.2_p48 ~3.2_p48-r1 ~4.0_p10 ~4.0_p10-r1 ~4.0_p17 ~4.0_p17-r1 ~4.0_p24 {afs bashlogger examples net nls plugins vanilla}
     Installed versions:  3.2_p39(17:21:03 08/04/09)(nls plugins -afs -bashlogger -examples -vanilla)
     Homepage:            http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html
     Description:         The standard GNU Bourne again shell

~ $
=====

As you can see, extglob is off. Since only subversion and surfraw seem to make use of extglob extensions, and I have installed surfraw only recently, is it possible that suvbersion-1.6.2 had disabled it by default? It is the stable version for amd64, as I showed before. What I know is that I have never tinkered with something the existence of wich I didn't know.

Thanks for your kindful help.
Comment 8 James Rowe 2009-07-24 09:25:11 UTC
(In reply to comment #7)
> ~ $ eix -I bash
> [I] app-shells/bash
>      Available versions:  3.1_p17 3.2_p39 ~3.2_p48 ~3.2_p48-r1 ~4.0_p10
> ~4.0_p10-r1 ~4.0_p17 ~4.0_p17-r1 ~4.0_p24 {afs bashlogger examples net nls
> plugins vanilla}
>      Installed versions:  3.2_p39(17:21:03 08/04/09)(nls plugins -afs
> -bashlogger -examples -vanilla)
>      Homepage:            http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html
>      Description:         The standard GNU Bourne again shell
> 
> ~ $

  app-shells/bash-completion shouldn't be missing from that output, and
therein lies the problem.  If you install the bash-completion package
all /should/ be well.  It also explains why there wasn't a lot more
output from your "grep '@(' /usr/share/bash-completion/*" call.  Please report
back your success or failure after installing app-shells/bash-completion.

  Thanks again for all the effort you're putting in with the extra info for 
this bug.
Comment 9 James Rowe 2009-07-24 17:25:39 UTC
  So yeah, I can reproduce and fix this bug now.  It just never occurred to me 
that people would choose to do that, so I missed it in the original report.  My 
bad.
Comment 10 James Rowe 2009-07-24 17:26:19 UTC
Created attachment 199002 [details, diff]
surfraw-fix_standalone_completion.patch

Jeroen,

  The fix I've attached makes surfraw bash completion work correctly for
people who do not wish to install the whole app-shells/bash-completion
package for whatever reason.

  My suggestion for the echangelog message is: "Fixed completion script
to work without app-shells/bash-completion installed, many thanks to
urcindalo in Bug #277891."

Thanks,

James
Comment 11 Jeroen Roovers (RETIRED) gentoo-dev 2009-07-25 05:58:18 UTC
Well, that worked out quite well, I think. I must note that I wasn't previously aware of this Gentoo specific patch at all. It's in the tree now. Thanks everyone.
Comment 12 urcindalo 2009-07-27 07:49:39 UTC
>   My suggestion for the echangelog message is: "Fixed completion script
> to work without app-shells/bash-completion installed, many thanks to
> urcindalo in Bug #277891."

I feel blushed. I did nothing to solve it. I just followed your directions.

By the way, I have bash-completion in my USE flags:

===
~ $ cat /etc/make.conf | grep bash
     avahi bash-completion bcmath bdf beagle binary-drivers binfilter blas \
~ $ sudo euse -I bash-completion
global use flags (searching: bash-completion)
************************************************************
[+ C  ] bash-completion - Enable bash-completion support

Installed packages matching this USE flag:
app-admin/eselect-1.1.1
app-portage/genlop-0.30.8-r2
app-text/tree-1.5.2.2
dev-util/git-1.6.3.3
dev-util/subversion-1.6.3
gnome-base/gvfs-1.0.3-r2
www-client/surfraw-2.2.5

local use flags (searching: bash-completion)
************************************************************
no matching entries found
~ $
===

Why, if I have this USE flag enabled, the bash-completion package is not installed as a dependency?
Comment 13 James Rowe 2009-07-27 16:15:01 UTC
> ------- Comment #12 from urcindalo@gmail.com  2009-07-27 07:49 0000 -------
> By the way, I have bash-completion in my USE flags:
<snip>
> Why, if I have this USE flag enabled, the bash-completion package is not
> installed as a dependency?

  Many packages don't explicitly require the app-shells/bash-completion
package for their completion support, and this now includes surfraw.
While it definitely provides additional functionality it shouldn't
normally break systems when it isn't installed, you just found a case
that hadn't been tested properly.  I should add that it requires
more user work to function without it but it does work, and if you've
been using the completion from git and subversion without
bash-completion installed you're obviously up to doing the configuration
work yourself.

  If you've synced the portage tree since Saturday and re-emerge surfraw
and you'll see it now works with or without app-shells/bash-completion
installed when properly configured.  Note that surfraw won't be
automatically upgraded as it isn't a critical fix, just in case that
wasn't clear.

  Finally, if you think app-shells/bash-completion should be installed
automatically with USE=bash-completion my guess would be that it is a bug
that needs to be filed separately with the maintainer of 
bash-completion.eclass, if there isn't one already of course.

Thanks,

James