zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Read file with escaped newlines into array
Date: Tue, 10 May 2016 09:15:34 -0700	[thread overview]
Message-ID: <CAH+w=7Zpf0GZ374X8Hppn6xD9jvmecP_MTa5vmM2PTEuNhwKLg@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVAevePDEG6JRUCKXy9UY1jzR5HodSRVd_C=yK2T2UkL4w@mail.gmail.com>

On Tue, May 10, 2016 at 7:26 AM, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> On 19 November 2015 at 20:17, Bart Schaefer <schaefer@brasslantern.com> 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.


  reply	other threads:[~2016-05-10 16:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-19 17:34 Sebastian Gniazdowski
2015-11-19 19:17 ` Bart Schaefer
2015-11-19 20:14   ` Sebastian Gniazdowski
2016-05-10 14:26   ` Sebastian Gniazdowski
2016-05-10 16:15     ` Bart Schaefer [this message]
2016-05-10 18:10       ` Sebastian Gniazdowski
2015-11-20  1:17 ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Zpf0GZ374X8Hppn6xD9jvmecP_MTa5vmM2PTEuNhwKLg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).