Re: setvar MIA?

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

 



On Tue, Jan 11, 2011 at 10:00:33AM -0700, Eric Blake wrote:
> On 01/11/2011 09:54 AM, Aragon Gouveia wrote:
> > I wasn't sure of its status in POSIX.  It is useful for declaring
> > variable variables - tidier than eval and I imagine faster, eg.

> > index="1"
> > setvar var_${index} "value"

> > Will emulate it with a local function - thanks.

> Indeed, it looks like FreeBSD introduced it as shorthand for:

> setvar() { eval $1=\$2; }

> The speed difference between that function doing an eval and a shell
> builtin would be in the noise.  I don't know why FreeBSD even bothered
> to pollute the namespace with a builtin like that.

The setvar builtin was already present and documented in the initial
ash. FreeBSD simply inherited it. Dash inherited it too, but it was
removed in dash-0.4.14, 3 Apr 2003.

The use of Almquist's additions like this one is certainly questionable;
many of them have been removed. However, setvar has been available and
documented in /bin/sh in all versions of FreeBSD, which makes removal
less likely at this point.

-- 
Jilles Tjoelker
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux