How can I set the compatibility level in Bash 4?

Solution Unverified - Updated -

Issue

Some bash scripts that worked correctly on Red Hat Enterprise Linux 4 and 5 are not working since we upgraded to version 6. A script like the following used to work on versions prior to bash version 4.x shipped in RHEL 6:

$ [[ "20110228" =~ '^[0-9]{8}$' ]] && echo matches
$

In previous bash versions it printed matches

Environment

  • Red Hat Enterprise Linux 6
  • Bash 4.X

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content