[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setvalue builtin command

From: Greg Wooledge
Subject: Re: setvalue builtin command
Date: Thu, 4 Apr 2013 08:39:13 -0400
User-agent: Mutt/

On Thu, Apr 04, 2013 at 02:26:34AM -0500, Dan Douglas wrote:
> > On Wed, Feb 6, 2013 at 11:30 AM, konsolebox <address@hidden> wrote:
> > > Hi. I was wondering if we could add a builtin where we could use it as an
> > > alternative for assigning values to a parameter. And thought of a builtin
> > > name called setvalue. With it we could assign values to a normal variable,
> > > an array, or an associative array.
> This is more or less identical to the ksh88 `set -A'. If anything were to be 
> added, it would probably be that. I assume Chet preferred enforcing more 
> consistent syntax rather than adding something redundant to ksh93-like 
> compound assignment syntax.
> The primary advantages to set -A are:
>  - It's the most portable way to assign multiple elements to an indexed array 
> other than a separate assignment for each element.
>  - The combination `set -sA' provides a means of sorting (lexicographically). 

It's also very much like the Tcl "set" command.

Another "feature" of this kind of construct is that you can put the name
of the variable-to-be-assigned into another variable:

setvalue "$ptr" "$foo"

Which may be a good thing or a bad thing, but either way it's definitely
a thing that someone will (ab)use if it's available.

That said, I don't think bash needs this.  Bash 4.3 is going to have
"namerefs" (declare -n) to allow passing arguments by reference to a

reply via email to

[Prev in Thread] Current Thread [Next in Thread]