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

Re: [BUG] 'case' pattern matching bug with bracket expressions



Martijn Dekker schreef op 14-05-15 om 14:14:
> The same thing does NOT produce an error, but a false positive (!), if
> an extra non-matching pattern with | is added:
> 
> case abc in ( [] | *[!a-z]*) echo yes ;; ( * ) echo no ;; esac
> 
> Expected output: no
> Got output: yes

I tested some more and found the bug is very specific, occurring only if
the second bracket expression (after the |) both starts with the "!"
negator *and* is followed (not necessarily preceded) by a '*' wildcard.

Test cases:

case abc in ( [] | nonmatching ) echo yes ;; ( * ) echo no ;; esac
Expected output: no
Got output: no

case abc in ( [] | *[A-Z]* ) echo yes ;; ( * ) echo no ;; esac
Expected output: no
Got output: no

case abc in ( [] | *[!a-z] ) echo yes ;; ( * ) echo no ;; esac
Expected output: no
Got output: no

case abc in ( [] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac
Expected output: no
Got output: yes    <-- !!!!

Thanks,

- Martijn



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