Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: f() { local -ar path=(/bin); };f gives an error
- X-seq: zsh-workers 42053
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Eric Cook <llua@xxxxxxx>
- Subject: Re: f() { local -ar path=(/bin); };f gives an error
- Date: Mon, 27 Nov 2017 20:17:21 +0000
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=zg7O2lgg27yrjkTf/VS0WlTitqavWiDARU2hpba1VZs=; b=gMFiKuLKbjG9ItakPJdXkyVfGHyZl8ppMfJLMJwmfmbTjVlOA7+ejrSvKdESdBWu8H q21/dE+UD888cCows5plhdwnCY17cOuhywl/ljvC5L98sTHNC/Xzte2zMVlDHWIBCw4K /0qngS5lpQCgtN8cnSFLurZBDXn6pETZQalQdNbm3u7JQRjRxAvfV+4xzKNCOgAaCwWw kZW4EpHl8FEgVbphhobhsueCeMJCnSE+ocoWMJDDgfyVfAusY+fkS/8V8xFwOPLCCweX 1VO4dz939NcqW9XhX3iOwgSU6joo/3H7yIJ4MWZpAsWCZrC6dqNWBKTM5hbN9LjrPikY LJHA==
- In-reply-to: <7a5807b1-0c5e-8134-a651-83e8b3df4d82@gmx.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Eric Cook <llua@xxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20171126232101.GA8393@chaz.gmail.com> <7a5807b1-0c5e-8134-a651-83e8b3df4d82@gmx.com>
2017-11-26 18:28:17 -0500, Eric Cook:
> On 11/26/2017 06:21 PM, Stephane Chazelas wrote:
> > FYI,
> >
> > someone reported this on unix.stackexchange.com:
> > https://unix.stackexchange.com/questions/407125/why-cant-i-define-a-readonly-variable-named-path-in-zsh
> >
> > Which looks like a bug:
> >
> > $ zsh -c 'f() { local -ar path=(/bin); }; f'
> > f: read-only variable: path
> > $ /zsh --version
> > zsh 5.4.2-dev-0 (x86_64-unknown-linux-gnu)
> >
> > See also the answer there by someone would did some investigation already.
> >
> () { local -har path=(/foo); typeset -p path }
> typeset -ar path=( /foo )
>
> -h Hide: only useful for special parameters (those marked
> `<S>' in the table in zshparam(1)), and for local parame‐
> ters with the same name as a special parameter...
Thanks.
But that creates a non-special local "path" variable.
The issue here is that when you're trying to make $path (the
special array variable tied to $PATH) readonly (with a value)
locally in a function, that doesn't work.
it also doesn't work with the scalar variant:
() { local -r PATH=/foo; }
same goes with the $cdpath/$CDPATH variable.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author