From owner-svn-src-head@FreeBSD.ORG Tue Apr 27 20:40:50 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 110071065672; Tue, 27 Apr 2010 20:40:50 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id CCCD48FC13; Tue, 27 Apr 2010 20:40:49 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id A41B535A828; Tue, 27 Apr 2010 22:33:52 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 995D017531; Tue, 27 Apr 2010 22:33:52 +0200 (CEST) Date: Tue, 27 Apr 2010 22:33:52 +0200 From: Jilles Tjoelker To: Andrey Chernov , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG Message-ID: <20100427203352.GB7165@stack.nl> References: <201004252043.o3PKhJi7065713@svn.freebsd.org> <20100427035224.GA87611@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100427035224.GA87611@nagual.pp.ru> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: Re: svn commit: r207206 - head/bin/sh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2010 20:40:50 -0000 On Tue, Apr 27, 2010 at 07:52:25AM +0400, Andrey Chernov wrote: > On Sun, Apr 25, 2010 at 08:43:19PM +0000, Jilles Tjoelker wrote: > > Author: jilles > > Date: Sun Apr 25 20:43:19 2010 > > New Revision: 207206 > > URL: http://svn.freebsd.org/changeset/base/207206 > > > > Log: > > sh: Use stalloc for arith variable names. > > > > This is simpler than the custom memory tracker I added earlier, and is also > > needed by the dash arith code I plan to import. > Just wonder, do you have plans to implement ${!variable} sometimes? > This bashism is very useful: > VAR_a1=foo > x=VAR_a1 > echo ${!x} This doesn't do anything you cannot do with eval: eval echo \$$x Furthermore, note that ksh93 and recent versions of mksh have almost the opposite meaning for ${!variable}, for example VAR_a1=foo typeset -n x=VAR_a1 echo $x:${!x} which prints foo:VAR_a1 (Explanation: typeset -n creates a "nameref" which redirects assignment and expansion to the variable name specified in the initial assignment. ${!X} expands to the name of the variable which is X unless X is a nameref.) We do have the setvar builtin for the reverse operation, inherited from the original ash, but I wouldn't have added this as it is likewise easily done with eval. The list assignment syntax setvar var word1 ... wordN has never been implemented, and I don't think it adds anything above ksh's syntaxes var=(word1 ... wordN) and set -A var word1 ... wordN -- Jilles Tjoelker