* Global array actually not available
@ 2016-06-30 14:34 Sebastian Gniazdowski
2016-06-30 14:56 ` Sebastian Gniazdowski
2016-06-30 17:04 ` Bart Schaefer
0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-06-30 14:34 UTC (permalink / raw)
To: Zsh Users
Hello
In code, I declare reply2 and reply3 as arrays via typeset -ga. I do
this from inside of a function. When the code returns to outer scope,
(t)reply2 and (t)reply3 show empty strings. The following lines start
at line 293 in lib/script_functions:
typeset -ga reply2 reply3
echo "T1 ${(t)reply} T2 ${(t)reply2} T3 ${(t)reply3}"
reply=( "${existing[@]}" )
reply2=( "${files[@]}" )
reply3=( "${sections[@]}" )
This is inner scope. The outer scope (line 1148 in zsh-select-zekyll) does:
filter_for_existing_zekylls "${zekylls[@]}"
three_to_section_order "${#reply}" "${reply[@]}" "${reply2[@]}"
"${reply3[@]}"
echo "t1 ${(t)reply} t2 ${(t)reply2} t3 ${(t)reply3}"
local -a existing files sections
existing=( "${reply[@]}" )
files=( "${reply2[@]}" )
sections=( "${reply3[@]}" )
echo "existing count: ${#existing}, files count: ${#files},
sections count: ${#sections}"
t1-t3 show empty string. Assigning ${reply2[@]} to files=( ... ) cause
the variable files to contain one mysterious element – it is empty,
probably.
To run the code first download zekyll, the investigation branch:
https://github.com/psprint/zekyll/tree/investig
it has to be unpacked to ~/.zekyll, final directory "zekyll", so full
path ~/.zekyll/zekyl. One can also use install script:
wget https://github.com/psprint/zekyll/blob/master/install.sh
sh ./install.sh
Next, one also needs a zkl repository available under
~/.zekyll/repos/{the-zkl-repo} or somewhere else (the path below after
-mp must match). It can be downloaded from:
https://github.com/psprint/zkl
After that, simply run command:
zkview -mp "/Users/sgniazdowski/github/zkl.git" --zkl
aaaaabaacaadaaeaafaagaahaaiaajaakaalaamaanaaoaap
Errorneous output will be created:
Read: aaaaabaacaadaaeaafaagaahaaiaajaakaalaamaanaaoaap
Checking current zekyll for duplicates...
T1 T2 array T3 array
-> aaa.A--Mainly_Exports
-> aab.A--Setopts_all
-> aad.B--Autoloads_tools_binds
-> aac.C--Bindkeys
-> aaf.D--Old_functions
-> aae.E--Aliases_all
-> aag.F--Tools_functions
-> aah.F--Other_functions
-> aaj.F--Off
-> aai.G--Hack
-> aak.H--Zplugin
-> aal.H--Zsh_navigation_tools
-> aam.I--Zstyles
-> aap.J--Completion
-> aan.K--Prompt_selection_final_setup
-> aao.L--Very_final
t1 t2 t3
existing count: 1, files count: 1, sections count: 1
Best regards,
Sebastian Gniazdowski
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Global array actually not available
2016-06-30 14:34 Global array actually not available Sebastian Gniazdowski
@ 2016-06-30 14:56 ` Sebastian Gniazdowski
2016-06-30 17:04 ` Bart Schaefer
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-06-30 14:56 UTC (permalink / raw)
To: Zsh Users
Sorry apparently I missed the fact that zkview runs two programs,
itself and zsh-select-zekyll. Maybe I will clarify what can be wrong
if at all.
Best regards,
Sebastian Gniazdowski
On 30 June 2016 at 16:34, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> Hello
>
> In code, I declare reply2 and reply3 as arrays via typeset -ga. I do
> this from inside of a function. When the code returns to outer scope,
> (t)reply2 and (t)reply3 show empty strings. The following lines start
> at line 293 in lib/script_functions:
>
> typeset -ga reply2 reply3
> echo "T1 ${(t)reply} T2 ${(t)reply2} T3 ${(t)reply3}"
> reply=( "${existing[@]}" )
> reply2=( "${files[@]}" )
> reply3=( "${sections[@]}" )
>
> This is inner scope. The outer scope (line 1148 in zsh-select-zekyll) does:
>
> filter_for_existing_zekylls "${zekylls[@]}"
> three_to_section_order "${#reply}" "${reply[@]}" "${reply2[@]}"
> "${reply3[@]}"
>
> echo "t1 ${(t)reply} t2 ${(t)reply2} t3 ${(t)reply3}"
> local -a existing files sections
> existing=( "${reply[@]}" )
> files=( "${reply2[@]}" )
> sections=( "${reply3[@]}" )
>
> echo "existing count: ${#existing}, files count: ${#files},
> sections count: ${#sections}"
>
> t1-t3 show empty string. Assigning ${reply2[@]} to files=( ... ) cause
> the variable files to contain one mysterious element – it is empty,
> probably.
>
>
> To run the code first download zekyll, the investigation branch:
> https://github.com/psprint/zekyll/tree/investig
>
> it has to be unpacked to ~/.zekyll, final directory "zekyll", so full
> path ~/.zekyll/zekyl. One can also use install script:
>
> wget https://github.com/psprint/zekyll/blob/master/install.sh
> sh ./install.sh
>
> Next, one also needs a zkl repository available under
> ~/.zekyll/repos/{the-zkl-repo} or somewhere else (the path below after
> -mp must match). It can be downloaded from:
>
> https://github.com/psprint/zkl
>
> After that, simply run command:
>
> zkview -mp "/Users/sgniazdowski/github/zkl.git" --zkl
> aaaaabaacaadaaeaafaagaahaaiaajaakaalaamaanaaoaap
>
> Errorneous output will be created:
>
> Read: aaaaabaacaadaaeaafaagaahaaiaajaakaalaamaanaaoaap
>
> Checking current zekyll for duplicates...
>
> T1 T2 array T3 array
> -> aaa.A--Mainly_Exports
> -> aab.A--Setopts_all
> -> aad.B--Autoloads_tools_binds
> -> aac.C--Bindkeys
> -> aaf.D--Old_functions
> -> aae.E--Aliases_all
> -> aag.F--Tools_functions
> -> aah.F--Other_functions
> -> aaj.F--Off
> -> aai.G--Hack
> -> aak.H--Zplugin
> -> aal.H--Zsh_navigation_tools
> -> aam.I--Zstyles
> -> aap.J--Completion
> -> aan.K--Prompt_selection_final_setup
> -> aao.L--Very_final
> t1 t2 t3
> existing count: 1, files count: 1, sections count: 1
>
>
> Best regards,
> Sebastian Gniazdowski
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Global array actually not available
2016-06-30 14:34 Global array actually not available Sebastian Gniazdowski
2016-06-30 14:56 ` Sebastian Gniazdowski
@ 2016-06-30 17:04 ` Bart Schaefer
1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2016-06-30 17:04 UTC (permalink / raw)
To: Zsh Users
On Jun 30, 4:34pm, Sebastian Gniazdowski wrote:
}
} In code, I declare reply2 and reply3 as arrays via typeset -ga. I do
} this from inside of a function. When the code returns to outer scope,
} (t)reply2 and (t)reply3 show empty strings.
I see your follow-up in which it appears this may be attributable to
separate shell processes, but in addition please note that typeset -g
does not actually declare a "global" variable (despite the mnemonic).
It merely declares a "non-local" variable. The actual dynamic scope
of the variable will be the nearest surrounding scope in which that
parameter's name is already defined (even if both defined AND unset;
in the unset case it may become set again, but it's scope remains).
Thus "typeset -g name" declares a true global $name only when there
is not another $name already declared (or $name is already global,
of course).
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-30 17:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-30 14:34 Global array actually not available Sebastian Gniazdowski
2016-06-30 14:56 ` Sebastian Gniazdowski
2016-06-30 17:04 ` Bart Schaefer
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).