Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 163527 - bash-3.2 =~ operator is mis-handling quotes
Summary: bash-3.2 =~ operator is mis-handling quotes
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo's Team for Core System packages
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Keywords:
: 177755 178009 191485 212346 (view as bug list)
Depends on:
Blocks: 162018
  Show dependency tree
 
Reported: 2007-01-24 01:14 UTC by Kevin F. Quinn (RETIRED)
Modified: 2008-03-05 07:39 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin F. Quinn (RETIRED) gentoo-dev 2007-01-24 01:14:12 UTC
Several people have reported that bash-3.2 doesn't handle quotes properly with the =~ operator - here's my example:

$ V="alphabet"
$ [[ $V =~ "alphabet" ]] && echo yes

should say "yes" (which it does on 3.1), but it doesn't.  I queried this on the bash-bugs mailing list, and the upstream maintainer shows how his 3.2 works properly (http://lists.gnu.org/archive/html/bug-bash/2007-01/msg00090.html) which puts the ball back in our court.

I've built bash on i686, ppc, ppc64, vanilla and hardened, with and without our patches (but always to upstream patchlevel 9), and it always does the same for me - i.e. it always fails to do the comparison properly; it'll only work if the quotes are dropped.

Remains to be seen if upstream have any suggestions; but it occurred to me that it could be an impact from something else (glibc, for example).

RedHat see the same behaviour that we do:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=220087



Here's an emerge info; since it happens on x86 vanilla I figure that's most relevant.
Portage 2.1.2 (default-linux/x86/2006.1, gcc-4.1.1, glibc-2.4-r4, 2.6.18-gentoo-r6 i686)
=================================================================
System uname: 2.6.18-gentoo-r6 i686 AMD Athlon(tm) XP 2500+
Gentoo Base System version 1.12.6
Timestamp of tree: Wed, 17 Jan 2007 23:30:01 +0000
dev-java/java-config: 1.3.7, 2.0.31
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.61
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=athlon-xp -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-O2 -march=athlon-xp -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig collision-protect cvs distlocks fixpackages installsources metadata-transfer pax sandbox sfperms sign splitdebug strict test userpriv"
GENTOO_MIRRORS="http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://gentoo.osuosl.org/"
LC_ALL="en_GB.utf8"
LDFLAGS="-Wl,-O1"
LINGUAS="en_GB en it de es fr"
MAKEOPTS="-j1"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext X a52 aac acl acpi alsa apache2 arts audiofile berkdb bitmap-fonts bzip2 cairo caps cdparanoia cdr cli cracklib crypt cups dbus dlloader dri dts dv dvb dvd dvdr dvdread encode ffmpeg firefox flac flash foomaticdb fortran gcj gdbm gif gpm gstreamer gtk gtk2 hal iconv imagemagick imap imlib ipod ipv6 isdnlog jack java javascript jpeg jpeg2k kde ldap lesstif libg++ mad mime ming mmap mmx mmxext mng mp3 mpeg mplayer nas ncurses nls nptl nptlonly nsplugin offensive ogg opengl pam pcre pda pdf perl png ppds pppd python qt3 qt4 quicktime readline reflection ruby samba session speex spell spl sse sse2 ssl svg tcl tcltk tcpd test tetex theora threads tidy tiff tk truetype truetype-fonts type1-fonts udev unicode usb v4l v4l2 vcd vdr vim-syntax vorbis wifi win32codecs wmf x264 x86 xine xinerama xml xmlrpc xorg xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_GB en it de es fr" USERLAND="GNU" VIDEO_CARDS="radeon vesa vga"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 1 SpanKY gentoo-dev 2007-01-24 03:23:03 UTC
Chet is looking at it further as he's confirmed it doesnt work for him on Linux but does work for him elsewhere
Comment 2 Kevin F. Quinn (RETIRED) gentoo-dev 2007-01-24 07:53:08 UTC
Yep.  Just want to be sure this blocks bash-3.2 from going stable.  We don't use =~ much (java-vm.eclass, java-utils-2.eclass and my acroread ebuild in the tree which all have no quotes now, and one commented-out use in baselayout 1.12.8 that does have single quotes) but it could have an impact on user scripts.
Comment 3 Kevin F. Quinn (RETIRED) gentoo-dev 2007-02-12 11:06:53 UTC
Upstream response:
http://www.mail-archive.com/bug-bash@gnu.org/msg02445.html

Problem is that bash is relying on undefined behaviour in regex handling.  BSD libc chooses to interpret a back-slashed non-special character in regexes as just the character, however glibc chooses to interpret them as a back-slash and the character.

I guess Chet is working to fix this, although he did say it would be awkward.
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2007-05-09 10:43:16 UTC
*** Bug 177755 has been marked as a duplicate of this bug. ***
Comment 5 Kevin F. Quinn (RETIRED) gentoo-dev 2007-05-09 19:46:23 UTC
See also the thread terminating in http://www.mail-archive.com/bug-bash%40gnu.org/msg02590.html

3.2 behaviour is correct - upshot is that my bug is INVALID :)

FI Patch 10 (the one the above thread is a response to) fixed a separate bug in the same operator, where bash internally was quoting all characters, rather than just the ones specifically defined in the standard to be quotable.  Unfortunately, the behaviour for other characters is undefined by the standard, and glibc chooses different behaviour to BSD's libc.
Comment 6 Jakub Moc (RETIRED) gentoo-dev 2007-05-11 08:30:12 UTC
*** Bug 178009 has been marked as a duplicate of this bug. ***
Comment 7 Jakub Moc (RETIRED) gentoo-dev 2007-05-11 08:30:53 UTC
(In reply to comment #5)
> 3.2 behaviour is correct - upshot is that my bug is INVALID :)

Reopen to resolve properly.
Comment 8 Jakub Moc (RETIRED) gentoo-dev 2007-09-06 11:19:27 UTC
*** Bug 191485 has been marked as a duplicate of this bug. ***
Comment 9 Jakub Moc (RETIRED) gentoo-dev 2008-03-05 07:39:09 UTC
*** Bug 212346 has been marked as a duplicate of this bug. ***