From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12759 invoked by alias); 19 Jul 2014 12:32:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18963 Received: (qmail 26430 invoked from network); 19 Jul 2014 12:32:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Sat, 19 Jul 2014 14:31:59 +0200 From: Moritz Bunkus To: zsh-users@zsh.org Subject: inconsistency in empty argument matching =~/pcre_match Message-ID: <20140719123158.GO12213@bunkus.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="s9kDAZ2EyO0AcRYa" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Virus-Scanned: clamav-milter 0.98.1 at liselle X-Virus-Status: Clean --s9kDAZ2EyO0AcRYa Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hey, if I load zsh/pcre and try to match empty lines then =~ and pcre_match will behave differently. Consider this test script: ---------------------------------------- #!/bin/zsh zmodload zsh/pcre line= if [[ $line =~ '^$' ]] print is empty case 1 pcre_compile '^$' pcre_match "$line" && print is empty case 2 pcre_match $line && print is empty case 3 ---------------------------------------- The output is: ---------------------------------------- is empty case 1 ./test.sh:pcre_match:10: not enough arguments ---------------------------------------- Meaning: 1. =~ matches as expected 2. pcre_match "$line" does NOT match and doesn't emit an error message 3. pcre_match $line does NOT match either and emits an error message This is not only inconsistent but also simply wrong. Both 2. and 3. should match, and 2. shouldn't emit an error message. Kind regards, mosu --s9kDAZ2EyO0AcRYa Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iD8DBQFTymU+vM968LZXH8oRAjT6AKDU2sYFJbETPf4pfJiY2FyUDmeHmQCcDPqe 3o0a1NjMTkpxGs10WkazrGY= =0IJw -----END PGP SIGNATURE----- --s9kDAZ2EyO0AcRYa--