DASH Shell discussions
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: Eric Blake <eblake@redhat.com>
Cc: Aragon Gouveia <aragon@phat.za.net>, dash@vger.kernel.org
Subject: Re: setvar MIA?
Date: Tue, 11 Jan 2011 20:58:12 +0100	[thread overview]
Message-ID: <20110111195811.GA62146@stack.nl> (raw)
In-Reply-To: <4D2C8CB1.4070204@redhat.com>

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

      reply	other threads:[~2011-01-11 19:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 15:54 setvar MIA? Aragon Gouveia
2011-01-11 16:10 ` Eric Blake
2011-01-11 16:54   ` Aragon Gouveia
2011-01-11 17:00     ` Eric Blake
2011-01-11 19:58       ` Jilles Tjoelker [this message]

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=20110111195811.GA62146@stack.nl \
    --to=jilles@stack.nl \
    --cc=aragon@phat.za.net \
    --cc=dash@vger.kernel.org \
    --cc=eblake@redhat.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox