Bug 681940 - change in case evaluation handling
Summary: change in case evaluation handling
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 15
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Roman Rakus
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-03-03 16:34 UTC by Nathanael Noblet
Modified: 2014-01-13 00:13 UTC (History)
4 users (show)

Fixed In Version: bash-4.2.7-1.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-03-09 03:08:08 UTC


Attachments (Terms of Use)
Patch from upstream (392 bytes, patch)
2011-03-03 19:42 UTC, Roman Rakus
no flags Details | Diff
How bash was built (1.62 KB, application/octet-stream)
2011-03-03 21:13 UTC, Nathanael Noblet
no flags Details

Description Nathanael Noblet 2011-03-03 16:34:52 UTC
Description of problem:
Between bash 4.1.x and 4.2.0 the way bash handles case evaluations has changed.

Version-Release number of selected component (if applicable):
4.2.0

How reproducible:
Always

Steps to Reproduce:
1. using the following script:

case x"" in
  x) echo 'expected'
     ;;
  x??) echo 'this would be really odd'
     ;;
  x?) echo 'does this prove anything?'
      echo x""x
     ;;
  *) echo 'no match'
     ;;
esac

2. call the script
3.
  
Actual results:
=> does this prove anything?
   xx


Expected results:
=> 'expected'

Additional info:

Comment 1 Nathanael Noblet 2011-03-03 18:06:45 UTC
bashbug-32 is unable to send this from mock I've tried manually sending it via bashbug etc... nothing seems to work. Perhaps as maintainer you have upstream contact?

Subject: change in case evaluation handling

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DDEBUG -DMALLOC_DEBUG -I.  -I. -I./include -I./lib  -D_GNU_SOURCE -DRECYCLES_PIDS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables
uname output: Linux iridium.gnat.ca 2.6.35.11-83.fc14.x86_64 #1 SMP Mon Feb 7 07:06:44 UTC 2011 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 4.2
Patch Level: 0
Release Status: rc2

Description:
	The following script illustrates a regression in handline case evaluations

case x"" in
  x) echo 'expected'
     ;;
  x??) echo 'this would be really odd'
     ;;
  x?) echo 'does this prove anything?'
      echo x""x
     ;;
  *) echo 'no match'
     ;;
esac

as output you get:

=>	does this prove anything
	xx

In bash 4.1.X you would get as output 'expected'. The issue was found by configure failing with lines like
case x"$enable_feature" in where enable_feature hadn't been passed to configure so the variable was undefined.
I should note that handling

if [ x"$some_undefined_var" = x ]; continues to function the same way as previous versions

Repeat-By:
	using the following script (named test_script for me):
======================================
#!/bin/sh

case x"$mytest" in
 xyes)
  echo "yes"
  ;;
 xno)
  echo "no"
  ;;
 x)
  echo "empty"
  ;;
 *)
  echo "not supported"
  ;;
esac

mytest=$1
case x"$mytest" in
 xyes)
  echo "yes"
  ;;
 xno)
  echo "no"
  ;;
 x)
  echo "empty"
  ;;
 *)
  echo "not supported"
  ;;
esac

exit;
=========================================

and call it with 

sh test_script yes
sh test_script no
sh test_script whatever
sh test_script

4.1.X has the following output:

- sh test_script yes
empty
yes

- sh test_script no
empty
no

- sh test_script whatever
empty
not supported

- sh test_script
empty
empty 

4.2.0 has the following output:
- sh test_script yes
not supported
yes

- sh test_script no
not supported
no

- sh test_script whatever
not supported
not supported

- sh test_script
not supported
not supported

Comment 2 Roman Rakus 2011-03-03 18:45:12 UTC
Thanks for the report. Reported upstream.

Comment 3 Roman Rakus 2011-03-03 18:58:20 UTC
Sooner or later it will be visible at http://lists.gnu.org/archive/html/bug-bash/2011-03/threads.html

Comment 4 Nathanael Noblet 2011-03-03 19:09:36 UTC
thanks - I'll keep tabs on that.

Comment 5 Roman Rakus 2011-03-03 19:42:08 UTC
Created attachment 482143 [details]
Patch from upstream

Can you please try this patch? It comes from upstream.

Comment 6 Nathanael Noblet 2011-03-03 21:13:44 UTC
Created attachment 482160 [details]
How bash was built

Just the git diff of current bash git head to my checkout and changes.

Comment 7 Nathanael Noblet 2011-03-03 21:14:14 UTC
Worse... Using http://fpaste.org/C018/

mock-chroot> sh test yes
empty
empty

mock-chroot> sh test
empty
empty

mock-chroot> sh test no
empty
empty

mock-chroot> sh test whatever
empty
empty


Vs F14:

> sh test yes
empty
yes

> sh test 
empty
empty

> sh test no
empty
no

> sh test whatever
empty
not supported

Comment 8 Nathanael Noblet 2011-03-03 21:15:26 UTC
Also you can see my bash package used for testing at 

http://iridium.gnat.ca/~gnat/smock/yum/fedora-15/i386

Comment 9 Roman Rakus 2011-03-03 21:44:24 UTC
I get the same results in F14 and rawhide bash (with the patch). The site http://iridium.gnat.ca/~gnat/smock/yum/fedora-15/i386 is not accessible for me.

Comment 10 Mamoru TASAKA 2011-03-04 20:36:21 UTC
(In reply to comment #5)
> Created attachment 482143 [details]
> Patch from upstream
> 
> Can you please try this patch? It comes from upstream.

This patch seems to work for me (patch applied against bash-4.2.6-1.fc15
src.rpm)

Comment 11 Fedora Update System 2011-03-07 13:01:23 UTC
bash-4.2.7-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/bash-4.2.7-1.fc15

Comment 12 Fedora Update System 2011-03-08 02:16:10 UTC
bash-4.2.7-1.fc15 has been pushed to the Fedora 15 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update bash'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/bash-4.2.7-1.fc15

Comment 13 Fedora Update System 2011-03-09 03:08:04 UTC
bash-4.2.7-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.