Please use declare -g ( or typeset -g, it's the same) to declaring global variables in functions. So, people who set setopt WARN_CREATE_GLOBAL won't get warning like such:
prompt_pure_check_cmd_exec_time:3: scalar parameter prompt_pure_cmd_exec_time created globally in function prompt_pure_check_cmd_exec_time
prompt_pure_check_cmd_exec_time:4: scalar parameter PURE_CMD_MAX_EXEC_TIME created globally in function prompt_pure_check_cmd_exec_time
prompt_pure_precmd:6: scalar parameter prompt_pure_cmd_timestamp created globally in function prompt_pure_precmd
prompt_pure_async_tasks:7: scalar parameter prompt_pure_async_init created globally in function prompt_pure_async_tasks
prompt_pure_preprompt_render:63: scalar parameter prompt_pure_last_prompt created globally in function prompt_pure_preprompt_render
setopt WARN_CREATE_GLOBAL in .zshrc..zshrc.Thanks, it's a good suggestion. I was in the process of changing this at some point, but it lies dormant in one of my git stashes 馃槢. I'll fix this soon!
Thanks! Please do that for setopt WARN_NESTED_VAR too.
I'll consider it, but I'm not making any promises. These warn options are mostly useful for development and shouldn't be enabled in day-to-day use (IMO). Sometimes setting nested vars is the wanted effect.
Well, you can still use nested vars if you want to with typeset -g / declare -g, and it won't make it global, it just suprese the error. Consider this example.
setopt WARN_NESTED_VAR
function toplevel() {
local foo="in toplevel"
nested
}
function nested() {
echo $foo # "in toplevel"
foo="in nested" # nested:3: scalar parameter foo set in enclosing scope in function nested in nested
declare -g foo="in nested"
declare -g bar="global"
echo $foo # "in nested"
}
toplevel
echo $foo # ""
echo $bar # "global"
Just pushed #347, can you confirm that it fixes your issues with warn_create_global? I opted for doing nothing about warn_nested_var although I'm not totally against it, but I would need to understand / see how making the changes necessary improves the code.
Thanks! It looks okay now, all of my errors are gone.
@mafredri
https://github.com/sindresorhus/pure/blob/a95d55cc7d3a73fc562ac11e23c26113ed6d58cf/pure.zsh#L402
I get errors about this variable.
Thanks for the report @kutsan, pushed a fix to master. Missed this one because I didn't have any unpushed/pulled commits when I tested this.
No problem! Thanks for quick fix! I really appreciate it.
By the way, the reason why it took so long to realize that it's because prompt was redrawing itself before I saw that error. Somehow, it appeared when I am messing with tmux panes. I would have told you if I saw that before. So, I'm sorry.
There鈥檚 absolutely no need to be sorry. It was good that this was caught now. 馃檪
And again.

I think you need to silence them with:
local match=
local mbegin=
local mend=
@kutsan thanks, fix is live on master!