bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regular Expression matching operation =~


From: Allodoxaphobia
Subject: Regular Expression matching operation =~
Date: 22 Sep 2019 21:44:34 GMT
User-agent: slrn/1.0.3 (FreeBSD)

In moving a bash ver. 4.3.48 (Ubuntu) program to a bash ver. 5.0.11 
(FreeBSD) environment I encountered either a bug, a quirk, or 
an undocumented feature.

I was using a null regexp as a "match for anything" case when an
optional command line parameter (a test pattern) was omitted.

I boiled down what I was experiencing to 

$ bash -version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
$ [[ "String" =~ "ring" ]] ; echo $?
0
$ [[ "String" =~ "" ]] ; echo $?
0
$    

$ bash -version
GNU bash, version 5.0.11(0)-release (amd64-portbld-freebsd12.0)
$ [[ "String" =~ "ring" ]] ; echo $?
0
$ [[ "String" =~ "" ]] ; echo $?
2
$

A null regexp works Just Fine in both the Ubuntu and FreeBSD
environments. E.g.:

$ grep "" /etc/shells

Jonesy
-- 
  Marvin L Jones    | Marvin      | W3DHJ.net  | linux
   38.238N 104.547W |  @ jonz.net | Jonesy     |  FreeBSD
    * Killfiling google & XXXXbanter.com: jonz.net/ng.htm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]