Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

inconsistency in empty argument matching =~/pcre_match



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: pgpEBdV4hZ2ij.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author