zsh-workers
 help / color / mirror / code / Atom feed
* WARN_CREATE_GLOBAL and parameters used by the shell
@ 2015-11-20 11:44 Vincent Lefevre
  2015-11-20 11:49 ` Peter Stephenson
  2015-11-20 11:55 ` Vincent Lefevre
  0 siblings, 2 replies; 4+ messages in thread
From: Vincent Lefevre @ 2015-11-20 11:44 UTC (permalink / raw)
  To: zsh-workers

I think that when WARN_CREATE_GLOBAL is set, one should get no warnings
for parameters used by the shell, as their intent is to be global.

For instance:

cventin% setopt WARN_CREATE_GLOBAL
cventin% foo() { RPS1="<" }
cventin% foo
foo: scalar parameter RPS1 created globally in function

There is no such problem with PS1, PS2, PS3 and PS4, probably because
they are already set by zsh.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


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

* Re: WARN_CREATE_GLOBAL and parameters used by the shell
  2015-11-20 11:44 WARN_CREATE_GLOBAL and parameters used by the shell Vincent Lefevre
@ 2015-11-20 11:49 ` Peter Stephenson
  2015-11-20 11:55 ` Vincent Lefevre
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2015-11-20 11:49 UTC (permalink / raw)
  To: zsh-workers

On Fri, 20 Nov 2015 12:44:56 +0100
Vincent Lefevre <vincent@vinc17.net> wrote:
> I think that when WARN_CREATE_GLOBAL is set, one should get no warnings
> for parameters used by the shell, as their intent is to be global.

Yes, we need to ignore specials, which are already in the namespace
anyway.

pws

diff --git a/Src/params.c b/Src/params.c
index 3ed771e..b121bd6 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2702,7 +2702,7 @@ check_warn_create(Param pm, const char *pmtype)
     Funcstack i;
     const char *name;
 
-    if (pm->level != 0)
+    if (pm->level != 0 || (pm->node.flags & PM_SPECIAL))
 	return;
 
     name = NULL;


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

* Re: WARN_CREATE_GLOBAL and parameters used by the shell
  2015-11-20 11:44 WARN_CREATE_GLOBAL and parameters used by the shell Vincent Lefevre
  2015-11-20 11:49 ` Peter Stephenson
@ 2015-11-20 11:55 ` Vincent Lefevre
  2015-11-20 12:01   ` Peter Stephenson
  1 sibling, 1 reply; 4+ messages in thread
From: Vincent Lefevre @ 2015-11-20 11:55 UTC (permalink / raw)
  To: zsh-workers

On 2015-11-20 12:44:56 +0100, Vincent Lefevre wrote:
> I think that when WARN_CREATE_GLOBAL is set, one should get no warnings
> for parameters used by the shell, as their intent is to be global.

I'm wondering... Can WARN_CREATE_GLOBAL be used in .zshenv or .zshrc?
There's a problem with smart-insert-last-word:

smart-insert-last-word:63: scalar parameter _ilw_lcursor created globally in function
smart-insert-last-word:76: scalar parameter _ilw_hist created globally in function
smart-insert-last-word:77: scalar parameter _ilw_count created globally in function
smart-insert-last-word:122: scalar parameter _ilw_cursor created globally in function
smart-insert-last-word:125: scalar parameter _ilw_changeno created globally in function

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


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

* Re: WARN_CREATE_GLOBAL and parameters used by the shell
  2015-11-20 11:55 ` Vincent Lefevre
@ 2015-11-20 12:01   ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2015-11-20 12:01 UTC (permalink / raw)
  To: zsh-workers

On Fri, 20 Nov 2015 12:55:38 +0100
Vincent Lefevre <vincent@vinc17.net> wrote:
> There's a problem with smart-insert-last-word:
> 
> smart-insert-last-word:63: scalar parameter _ilw_lcursor created globally in function
> smart-insert-last-word:76: scalar parameter _ilw_hist created globally in function
> smart-insert-last-word:77: scalar parameter _ilw_count created globally in function
> smart-insert-last-word:122: scalar parameter _ilw_cursor created globally in function
> smart-insert-last-word:125: scalar parameter _ilw_changeno created globally in function
> 

Those are all intentional.

pws

diff --git a/Functions/Zle/smart-insert-last-word b/Functions/Zle/smart-insert-last-word
index 67adea7..cf8715d 100644
--- a/Functions/Zle/smart-insert-last-word
+++ b/Functions/Zle/smart-insert-last-word
@@ -60,7 +60,7 @@ then
     lcursor=$_ilw_lcursor
 else
     NUMERIC=1
-    _ilw_lcursor=$lcursor
+    typeset -g _ilw_lcursor=$lcursor
 fi
 # Handle the up to three arguments of .insert-last-word
 if (( $+1 ))
@@ -73,8 +73,8 @@ then
     (( NUMERIC )) || LBUFFER[lcursor+1,cursor+1]=''
     numeric=$((-(${2:--numeric})))
 fi
-_ilw_hist=$HISTNO
-_ilw_count=$NUMERIC
+typeset -g _ilw_hist=$HISTNO
+typeset -g _ilw_count=$NUMERIC
 
 if [[ -z "$numeric" ]]
 then
@@ -119,7 +119,7 @@ fi
 (( NUMERIC > $#lastcmd )) && return 1
 
 LBUFFER[lcursor+1,cursor+1]=$lastcmd[-NUMERIC]
-_ilw_cursor=$CURSOR
+typeset -g _ilw_cursor=$CURSOR
 
 # This is necessary to update UNDO_CHANGE_NO immediately
-zle split-undo && _ilw_changeno=$UNDO_CHANGE_NO
+zle split-undo && typeset -g _ilw_changeno=$UNDO_CHANGE_NO


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

end of thread, other threads:[~2015-11-20 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 11:44 WARN_CREATE_GLOBAL and parameters used by the shell Vincent Lefevre
2015-11-20 11:49 ` Peter Stephenson
2015-11-20 11:55 ` Vincent Lefevre
2015-11-20 12:01   ` Peter Stephenson

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