zsh-users
 help / color / mirror / code / Atom feed
* case-insensitivity of =~ operator
@ 2014-07-19 12:19 Moritz Bunkus
  2014-07-19 12:31 ` inconsistency in empty argument matching =~/pcre_match Moritz Bunkus
  2014-07-19 12:36 ` case-insensitivity of =~ operator Moritz Bunkus
  0 siblings, 2 replies; 9+ messages in thread
From: Moritz Bunkus @ 2014-07-19 12:19 UTC (permalink / raw)
  To: zsh-users

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

Hey,

today I stumbled across this paragraph in zsh's info documentation
again. Citing »Description of Options«:

> CASE_MATCH <D>
>      Make regular expressions using the zsh/regex module (including
>      matches with =~) sensitive to case.

It does not apply to =~ if the zsh/pcre module is loaded. Test script:

----------------------------------------
#!/bin/zsh

export LC_ALL=C

zmodload zsh/pcre
setopt no_case_match

line=Hello
if [[ $line =~ He ]] print match case 1
if [[ $line =~ he ]] print match case 2
if [[ $line -pcre-match He ]] print match case 3
if [[ $line -pcre-match he ]] print match case 4

pcre_compile He
pcre_match $line && print match case 5

pcre_compile -i He
pcre_match $line && print match case 6
----------------------------------------

Output:

----------------------------------------
match case 1
match case 3
match case 5
match case 6
----------------------------------------

Yes, the paragraph above states zsh/regex and not zsh/pcre, but as
zsh/pcre's presence can be… well… it's hard(er) for scripts do detect.

What I'm asking for are two things:

1. Make the paragraph above a bit clearer. An example what would work
   for me:

   > Make regular expressions using the zsh/regex module (including
   > matches with =~ if the zsh/pcre module is not loaded) sensitive to
   > case.

2. Provide an option for making matches with zsh/pcre including
   pcre_match and =~ case-insensitive.

Alternatively extend CASE_MATCH to work on the =~ provided by zsh/pcre,
too and update the info section accordingly. This might make more sense
considering that pcre_match must be used with pcre_compile in tandem and
pcre_compile provides -i already.

Thanks for your consideration.

Kind regards,
mosu

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-07-20 17:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-19 12:19 case-insensitivity of =~ operator Moritz Bunkus
2014-07-19 12:31 ` inconsistency in empty argument matching =~/pcre_match Moritz Bunkus
2014-07-19 12:36   ` 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

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).