From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Cc: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
Date: Sun, 25 Jan 2015 13:39:31 -0800 [thread overview]
Message-ID: <150125133931.ZM32124@torch.brasslantern.com> (raw)
In-Reply-To: <10496951422218331@web21g.yandex.ru>
On Jan 25, 11:38pm, ZyX wrote:
} Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...}
}
} 25.01.2015, 23:25, "Bart Schaefer" <schaefer@brasslantern.com>:
} >
} > Don't we already have something like this for ksh emulation? Except that
} > it acts like (k) instead of like (P)? Although I can't find this in the
} > documentation anywhere, right at the moment.
}
} I have ksh installed and here `${!VAR}` outputs `VAR` regardless of
} whether $VAR is defined and what type and what value does it have.
I thought I recalled something about that. So it would appear that
whatever interpretation we're giving it already in ksh mode, is wrong.
} [Manual page][1] says that it should actually expand to "the name of
} the variable referred to by vname" and says that this will be `VAR`
} unless it is a name reference (I have only tried strings, arrays and
} associative arrays).
}
} [1]: http://unixhelp.ed.ac.uk/CGI/man-cgi?ksh+1
So it would appear that ${!var} in bash is ${(P)var} (just tried it, it
does so) where as ${!var} in ksh inhibits the expansion of a nameref
to its value and instead just prints the name to which the nameref
refers, which in zsh is [usually] just ${var}.
Interesting thing I didn't know about namerefs -- if you do
nameref foo=bar
nameref bar=baz
then the nameref for $foo is broken (${!foo} prints ".deleted"), but
if you do it the other way round
nameref bar=baz
nameref foo=bar
then ${!foo} prints "baz" and ${foo} gives the value of ${baz}.
--
Barton E. Schaefer
next prev parent reply other threads:[~2015-01-25 21:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-25 9:15 Tomoki Sekiyama
2015-01-25 18:14 ` Peter Stephenson
2015-01-25 18:23 ` Mikael Magnusson
2015-01-25 20:24 ` Bart Schaefer
2015-01-25 20:38 ` ZyX
2015-01-25 21:39 ` Bart Schaefer [this message]
2015-01-26 20:00 ` Tomoki Sekiyama
2015-01-26 20:44 ` ZyX
2015-01-27 5:48 ` Bart Schaefer
2015-01-28 3:21 ` Tomoki Sekiyama
2015-01-28 18:41 ` Bart Schaefer
2016-11-11 16:58 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150125133931.ZM32124@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=tomoki.sekiyama@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).