BASH’s compat31 option
By chys on January 9th, 2009Several of my bash scripts failed when I migrated from Debian to Gentoo almost one year ago for the different ways bash interpretes commands like this: [[ "$x" =~ '^[0-9]$' ]]. This command succeeded in Debian when $x is a single digit, but failed in Gentoo. I had to remove the single quotes surround the regular expression to make it work in Gentoo.
Today I finally found the reason: I was using bash 3.1 in Debian and 3.2 in Gentoo. Bash 3.2 by default mandates that regular expressions not be surrounded by quotes; however, the behavior can be modified using shopt -s compat31.
Related posts:
- Extended pattern matching in BASH
- How BASH Changes Terminal Window Title
- globstar in bash 4 follows directory symlinks
- Extract Deb files from command line
Tags: bash
Leave a Reply
Hint: Register at Gravatar and your comments will be accompanied by your personalized icon.

