From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24245 invoked by alias); 25 Jan 2015 21:40:02 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34397 Received: (qmail 3232 invoked from network); 25 Jan 2015 21:39:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=PYxIXZlY c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=YNv0rlydsVwA:10 a=aA-rkObNAAAA:8 a=dQGmURLLS_mVIGHJ9DQA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150125133931.ZM32124@torch.brasslantern.com> Date: Sun, 25 Jan 2015 13:39:31 -0800 In-reply-to: <10496951422218331@web21g.yandex.ru> Comments: In reply to ZyX "Re: [PATCH] Enable further expansion of parameter name by ${!...}" (Jan 25, 11:38pm) References: <1422177338-85472-1-git-send-email-tomoki.sekiyama@gmail.com> <150125122410.ZM31619@torch.brasslantern.com> <10496951422218331@web21g.yandex.ru> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-workers@zsh.org" Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...} Cc: Tomoki Sekiyama MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 25, 11:38pm, ZyX wrote: } Subject: Re: [PATCH] Enable further expansion of parameter name by ${!...} } } 25.01.2015, 23:25, "Bart Schaefer" : } > } > 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