Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Read file with escaped newlines into array
- X-seq: zsh-users 21544
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Read file with escaped newlines into array
- Date: Tue, 10 May 2016 20:10:32 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RCoauQr1MSpBLT/PuiNtHEZ+QTjNsBR/Xs12uZvcWWk=; b=q+DPG1PnKZR3Mp3fgR+SxDpVzn1dvqPhDAekdTThttZGKgJzEr/gFE0jNxgg3oqozt oQEoeljv/j+Rk1o3LIklOgcnDoGXrNUV5H2U3BXKqWewkKHC6k2mBZPsKpOaXffaHvkZ CIpqIzaHZN4QIWv30nKcuGtcLhq5cknSf/1j4nt67aNricG1Pn6A16SOyKMqLJH0Z9vE UsSyntovgiBdY9v1qI6TBVaXm7NdGpH+TC+dfKaT8xU2MEVnfukOu8sOwWjELgU8DnyS d4rRmwa0XXomSEGGW0W0FQA1Q2Z7Lu4FhcmTCatw59y4GsTRhjW41OP1+O21UndCmPbH v/4Q==
- In-reply-to: <CAH+w=7Zpf0GZ374X8Hppn6xD9jvmecP_MTa5vmM2PTEuNhwKLg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCZzEfKkcWyPUb58ffmne6E8Eh6_CDpeLc0efd6hEQAow@mail.gmail.com> <151119111749.ZM8874@torch.brasslantern.com> <CAKc7PVAevePDEG6JRUCKXy9UY1jzR5HodSRVd_C=yK2T2UkL4w@mail.gmail.com> <CAH+w=7Zpf0GZ374X8Hppn6xD9jvmecP_MTa5vmM2PTEuNhwKLg@mail.gmail.com>
On 10 May 2016 at 18:15, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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".
I use $history to refer to main history and also load a private
history by using the code you gave, and they don't interfere. You used
anonymous function suggesting $history is being localized and that's
how it in practice works. Read the manual (second time), it's -a that
makes the temporary structure switched to by fc -p to be automatically
dropped. Convenient.
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author