Bug 1623337 - [[ STRING =~ regex ]] command fails on case sensitivity
Summary: [[ STRING =~ regex ]] command fails on case sensitivity
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 28
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-08-29 06:33 UTC by Markus S
Modified: 2019-05-28 19:22 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-05-28 19:22:23 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
test case (202 bytes, application/x-shellscript)
2018-08-29 06:33 UTC, Markus S
no flags Details

Description Markus S 2018-08-29 06:33:19 UTC
Created attachment 1479395 [details]
test case

Description of problem:

The 

  [[ STRING =~ regex ]]

compound command gives sometimes false matches. It wrongly
matches lower case letters.

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

GNU bash, Version 4.4.23(1)-release (x86_64-redhat-linux-gnu)

How reproducible:

Use the attached bash script "mt" to check the following:

Steps to Reproduce:
1. ./mt MOa ; 
2. ./mt MOb

Actual results:
Output generated in step 1:
  no match
  match

Output generated in step 2:
  match
  match

Expected results:

Output generated in both steps should be identical, i.e.:

Output generated in step 1:
  no match
  match

Output generated in step 2:
  no match
  match


Additional info:

In opensuse tumbleweed, which provides bash with the same version number 
(4.4.23(1)-release (x86_64-suse-linux-gnu), this bug does NOT exist.

Comment 1 Markus S 2018-08-29 06:36:12 UTC
Note: In the attached test case #!/bin/sh is called, but this is symlinked to bash here. So effectively bash is called.

Comment 2 Kamil Dudka 2018-08-29 07:58:46 UTC
Did you try it with POSIX locale?

$ LC_ALL=C ./mt MOb
no match
match

Comment 3 Markus S 2018-08-29 11:50:49 UTC
Good catch. With LC_ALL=C it behaves correctly.

After further investigation, the behavior depends on LANG, which is set to de_DE.utf8 here.

I get buggy results with 
  LANG=de_DE.utf8,
  LANG=de_DE, 
  LANG=fr_FR,
  LANG=cs_CZ
  (others not checked)

and correct results when LANG is unset, "C", or unknown (such as "xx_YY")

The only other locale dependend environment variable that is set is:
LC_CTYPE=de_DE.iso8859-15@euro. LC_CTYPE aparrently does not affect this behavior.

Comment 4 Markus S 2018-08-29 13:31:33 UTC
OK, after reading 

https://unix.stackexchange.com/questions/15980/does-should-lc-collate-affect-character-ranges

and 

http://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html

at least there is some kind of explanation for the observed behavior (LC_COLLATE controlled, finally) and a workaround using [[:upper]].

Nevertheless, it's still questionable why 'a' is considered to be not in the range [A-Z] but 'b' (and other lower case letters) is.

Comment 5 Ben Cotton 2019-05-02 21:00:49 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 6 Ben Cotton 2019-05-28 19:22:23 UTC
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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