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

Bug in regexp operator when warn_create_global is in effect



Consider the following program:

   #!/bin/zsh
   function f {
      [[ x =~ x ]]
   }
   setopt warn_create_global
   f

When run by zsh 5.2 (x86_64-ubuntu-linux-gnu), I get the error messages:

f:1: scalar parameter MATCH created globally in function f
f:1: numeric parameter MBEGIN created globally in function f
f:1: numeric parameter MEND created globally in function f

While it is correct, that regexp matching sets, as side effect, the
variables mentioned here, it doesn't, IMHO, make much sense that a zsh
user, who not even *uses* these variables, receives these error
messages. If the user had to pay attention to those variables which
automatically spring into existence by zsh language constructs, doing a
cd inside a function should equally well raise the message "parameter
OLDPWD created globally in function".

I suggest that the variables MATCH, MBEGIN and MEND are already created
by zsh
as global parameters during shell startup time. This would not trigger
the warning, if someone uses regexp matching inside functions.

Ronald



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