0

Long story short:

bash --version | head -n 1; [[ "abc" =~ "^a" ]] && echo Match || echo No match

Results on host 1:

GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Match

Results on host 2:

GNU bash, version 4.1.2(1)-release (i386-redhat-linux-gnu)
No match

What environment directives and/or configuration options should I check in order to produce consistent results?

For completion, please be advised they don't always fail to match all regular expressions. Slightly altering the regular expression (removing the "beginning of string" caret constraint) does produce consistent results:

bash --version | head -n 1; [[ "abc" =~ "a" ]] && echo Match || echo No match

Results on host 1:

GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Match

Results on host 2:

GNU bash, version 4.1.2(1)-release (i386-redhat-linux-gnu)
Match
Bogdan Stăncescu
  • 5,320
  • 3
  • 24
  • 25
  • Regex should not be quoted. Use: `[[ "abc" =~ ^a ]] && echo Match || echo 'No match'` – anubhava Jan 08 '18 at 08:54
  • [related : bash regex with quotes?](https://stackoverflow.com/questions/218156/bash-regex-with-quotes), this seems to be a change between bash 3.1 and 3.2 – Nahuel Fouilleul Jan 08 '18 at 08:54

0 Answers0