Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Read-only variables in emulation mode



On Thu, Dec 19, 2013 at 8:57 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Dec 18,  7:28pm, Peter Stephenson wrote:
> } Subject: Re: Read-only variables in emulation mode
> }
> } On Tue, 17 Dec 2013 22:36:51 -0800
> } Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } > It's a known limitation that invoking "emulate ..." after the shell is
> } > already running does [not] completely re-instantiate POSIX mode.
> }
> } I don't expect I'll get round to it myself, but in the case of
> } variables, I don't think this should be that difficult.
>
> The part about "_" is easy, though:
>
> diff --git a/Src/params.c b/Src/params.c
> index 26ad6b2..cadf268 100644
> --- a/Src/params.c
> +++ b/Src/params.c
> @@ -283,7 +283,7 @@ IPDEF2("TERM", term_gsu, 0),
>  IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
>  IPDEF2("WORDCHARS", wordchars_gsu, 0),
>  IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT),
> -IPDEF2("_", underscore_gsu, PM_READONLY),
> +IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
>  IPDEF2("KEYBOARD_HACK", keyboard_hack_gsu, PM_DONTIMPORT),
>
>  #ifdef USE_LOCALE
>
>
> Feel free to commit that for me if you want it to go into 5.0.4, I'm
> going to be asleep for the next several hours ...

% echo hi; _=foo; echo $_
hi
hi

% for _ in a b c; do echo $_ hi; done
hi
hi hi
hi hi

I'm not sure if this is better than printing a warning that $_ is readonly. :)

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author