* -u option does not work with recursive expansion?
@ 2019-02-14 23:07 Dominik Vogt
2019-02-14 23:45 ` Mikael Magnusson
0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2019-02-14 23:07 UTC (permalink / raw)
To: Zsh Users
Why does the recursive expansion of foo not trigger an error
message with the -u option? Is that a bug? Is there some
woraround to get the expected error behaviour in all cases?
-- snip --
set -u
foo=bar
unset bar
# ==> bar: parameter not set
echo $bar
# ==> no error?
echo ${${foo}}
-- snip --
$ zsh --version
zsh 5.3.1 (x86_64-...-...-gnu)
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: -u option does not work with recursive expansion?
2019-02-14 23:07 -u option does not work with recursive expansion? Dominik Vogt
@ 2019-02-14 23:45 ` Mikael Magnusson
2019-02-15 0:41 ` Dominik Vogt
0 siblings, 1 reply; 5+ messages in thread
From: Mikael Magnusson @ 2019-02-14 23:45 UTC (permalink / raw)
To: dominik.vogt, Zsh Users
On 2/15/19, Dominik Vogt <dominik.vogt@gmx.de> wrote:
> Why does the recursive expansion of foo not trigger an error
> message with the -u option? Is that a bug? Is there some
> woraround to get the expected error behaviour in all cases?
>
> -- snip --
> set -u
> foo=bar
> unset bar
> # ==> bar: parameter not set
> echo $bar
> # ==> no error?
> echo ${${foo}}
> -- snip --
If the above command doesn't output bar, your shell is very broken. I
think you're confused about what ${${foo}} means though. Putting a ${}
inside another ${} doesn't perform indirect expansion, you need (P)
for that.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: -u option does not work with recursive expansion?
2019-02-14 23:45 ` Mikael Magnusson
@ 2019-02-15 0:41 ` Dominik Vogt
2019-02-15 1:10 ` Bart Schaefer
2019-02-15 1:41 ` Matthew Martin
0 siblings, 2 replies; 5+ messages in thread
From: Dominik Vogt @ 2019-02-15 0:41 UTC (permalink / raw)
To: Zsh Users
On Fri, Feb 15, 2019 at 12:45:28AM +0100, Mikael Magnusson wrote:
> On 2/15/19, Dominik Vogt <dominik.vogt@gmx.de> wrote:
> > Why does the recursive expansion of foo not trigger an error
> > message with the -u option? Is that a bug? Is there some
> > woraround to get the expected error behaviour in all cases?
> >
> > -- snip --
> > set -u
> > foo=bar
> > unset bar
> > # ==> bar: parameter not set
> > echo $bar
> > # ==> no error?
> > echo ${${foo}}
> > -- snip --
>
> If the above command doesn't output bar, your shell is very broken. I
> think you're confused about what ${${foo}} means though. Putting a ${}
> inside another ${} doesn't perform indirect expansion, you need (P)
> for that.
Yeah, you're right. My memory believes this was different at some
distant point in the past, i.e. that ${${A}} used to do recursive
expansion.
Well, with (P) it's possible to do recursive expansion at the
right side of an assigntment, but can you also do soething like
foo=bar
${foo}=baz
i.e. treat the contents of foo as the lvalue of an assignment?
(Without using eval, of course.)
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: -u option does not work with recursive expansion?
2019-02-15 0:41 ` Dominik Vogt
@ 2019-02-15 1:10 ` Bart Schaefer
2019-02-15 1:41 ` Matthew Martin
1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2019-02-15 1:10 UTC (permalink / raw)
To: dominik.vogt, Zsh Users
On Thu, Feb 14, 2019 at 4:47 PM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>
> Well, with (P) it's possible to do recursive expansion at the
> right side of an assigntment, but can you also do soething like
>
> foo=bar
> ${foo}=baz
>
> i.e. treat the contents of foo as the lvalue of an assignment?
Not directly, but you can do
typeset ${foo}=baz
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: -u option does not work with recursive expansion?
2019-02-15 0:41 ` Dominik Vogt
2019-02-15 1:10 ` Bart Schaefer
@ 2019-02-15 1:41 ` Matthew Martin
1 sibling, 0 replies; 5+ messages in thread
From: Matthew Martin @ 2019-02-15 1:41 UTC (permalink / raw)
To: dominik.vogt, Zsh Users
On Thu, Feb 14, 2019 at 6:47 PM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>
> Well, with (P) it's possible to do recursive expansion at the
> right side of an assigntment, but can you also do soething like
>
> foo=bar
> ${foo}=baz
>
> i.e. treat the contents of foo as the lvalue of an assignment?
> (Without using eval, of course.)
% foo=bar; : ${(P)foo::=baz}; typeset -p bar
typeset bar=baz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-15 1:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 23:07 -u option does not work with recursive expansion? Dominik Vogt
2019-02-14 23:45 ` Mikael Magnusson
2019-02-15 0:41 ` Dominik Vogt
2019-02-15 1:10 ` Bart Schaefer
2019-02-15 1:41 ` Matthew Martin
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).