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

Parameter aliasing? RE: PATCH: "typeset -m" plays havoc

> >     erase_PS1() { typeset PS1 prompt PROMPT }
> Hmm ... in case of prompts what (very probably) happens:
> - for the first parameter typeset_single() calls copyparam() to save old
> value; this creates new parameter and copies old *string* value.
> Then it sets
> value to "" creating new empty parameter - that actually sets variable
> "prompt" to empty string.
> - for the second and third parameters exactly the same happens ...
> but now the
> saved value is already empty string (all three actually refer to the same
> variable "prompt").

Note, that the same happens in case of three different typeset's as well.

The only clean general way to do it is to introduce real aliases instead of
separate parameters internally referencing the same value. In this case first
typeset would save original value and two others would simply do nothing
(well, they would actually print parameters value. But there is no real way to
avoid it).

One point to decide is: should 'unset alias' remove parameter itself (with all
aliases) or just unset current alias? And if we want user-defined aliases?


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