On Tue, May 10, 2016 at 7:26 AM, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
> On 19 November 2015 at 20:17, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>>
>> () { fc -ap -R the_given_file ; the_desired_array=( ${history} ) }
>
> This works, but I wonder, how it's possible that zsh/parameter
> variables such as $historywords are made local?
Special parameters can be made local simply by declaring them so. Or
are you asking "how" in the sense of what is done internally to make
it work?
In the case of $history et al., internally they reference the history
data structures directly, so "fc -p" implicitly makes $history refer
to the new temporary history, and then switch back to the real history
on "fc -P"; it isn't necessary to declare it local when using "fc
-ap".
Or perhaps you're asking how to populate a local variable called
"history" that does NOT track other history changes? In that case you
need to declare it with "local -h history" -- but if you do so, then
the real $history is hidden from all functions deeper in the call
stack, there is no way to get back to having $history refer to the
actual current history state until the declaring function returns.