zsh-users
 help / color / mirror / code / Atom feed
From: Moritz Bunkus <moritz@bunkus.org>
To: zsh-users@zsh.org
Subject: inconsistency in empty argument matching =~/pcre_match
Date: Sat, 19 Jul 2014 14:31:59 +0200	[thread overview]
Message-ID: <20140719123158.GO12213@bunkus.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

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

[-- Attachment #2: Type: application/pgp-signature, Size: 173 bytes --]

         reply	other threads:[~2014-07-19 12:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-19 12:19 case-insensitivity of =~ operator Moritz Bunkus
2014-07-19 12:31 ` Moritz Bunkus [this message]
2014-07-19 12:36   ` inconsistency in empty argument matching =~/pcre_match Moritz Bunkus
2014-07-19 22:21     ` Several PCRE module oddities Bart Schaefer
2014-07-20  7:40       ` Moritz Bunkus
2014-07-20 10:24       ` Roman Neuhauser
2014-07-20 16:14       ` Bart Schaefer
2014-07-20 17:19         ` Peter Stephenson
2014-07-19 12:36 ` case-insensitivity of =~ operator Moritz Bunkus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140719123158.GO12213@bunkus.org \
    --to=moritz@bunkus.org \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).