DASH Shell discussions
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: dash@vger.kernel.org, pape@smarden.org
Subject: Re: [PATCH 4/4] [VAR] Replace cmdenviron with localvars
Date: Thu, 27 May 2010 00:37:23 +0200	[thread overview]
Message-ID: <20100526223723.GB5679@stack.nl> (raw)
In-Reply-To: <E1OHELi-0006sy-Nn@gondolin.me.apana.org.au>

On Wed, May 26, 2010 at 09:00:34PM +1000, Herbert Xu wrote:
> [VAR] Replace cmdenviron with localvars

> This patch replaces the cmdenviron mechanism for temporary command
> variables with the localvars mechanism used by functions.

> This reduces code size, and more importantly, makes the variable
> assignment take effect immediately as required by POSIX.

This change breaks passing variable assignments to regular builtins.
For example,
  dash -c 'HOME=/ cd; pwd'
This should print /. (For some reason, this does not work in ksh93
either.)
Or
  dash -c 'cd /bin&&CDPATH=/ cd bin; pwd'
This should print /bin twice and not fail any command. (Again this fails
in ksh93.)

A more common example,
  IFS=: read -r x y z
is already broken in master before this change (due to git commit
55c46b7286f5d9f2d8291158203e2b61d2494420 which effectively replaced
bltinlookup("IFS") with ifsval()).

Similar issues may pop up with
  PATH=/foo command -V bar
  PATH=/foo type bar
  LC_NUMERIC=de_DE.UTF-8 printf '%f\n' 1,2

(Note: the latter is broken in bash, but in ksh93 and zsh it works, as
well as with an external printf(1) program.)

'local' may need additional magic to avoid making things local to the
temporary regular-builtin scope. I suppose only functions should induce
scope for 'local', such that things like command eval 'local i' continue
to create a variable local to the function.

-- 
Jilles Tjoelker

  reply	other threads:[~2010-05-26 22:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201004052231.28372.j6t@kdbg.org>
     [not found] ` <201004052257.58768.j6t@kdbg.org>
     [not found]   ` <20100407094356.GA16716@squonk.masqnet>
     [not found]     ` <201004072033.59546.j6t@kdbg.org>
     [not found]       ` <20100408081737.GA8018@squonk.masqnet>
     [not found]         ` <chaz20100408104928.GA3959@yahoo.fr>
     [not found]           ` <20100408111617.GB11737@squonk.masqnet>
     [not found]             ` <20100409033953.GA32629@gondor.apana.org.au>
     [not found]               ` <20100409082602.GA12973@squonk.masqnet>
2010-05-26 10:59                 ` Assignment with command: export only, or sets variable, too? Herbert Xu
2010-05-26 11:00                   ` [PATCH 1/4] [VAR] Add localvars nesting Herbert Xu
2010-05-26 21:55                     ` Jilles Tjoelker
2010-05-27  3:34                       ` Herbert Xu
2010-05-27  7:16                         ` [PATCH 1/2] [REDIR] Move null redirect checks into caller Herbert Xu
2010-05-27  7:16                         ` [PATCH 2/2] [REDIR] Fix popredir on abnormal exit from built-in Herbert Xu
2010-05-26 11:00                   ` [PATCH 2/4] [VAR] Fix poplocalvar leak Herbert Xu
2010-05-26 11:00                   ` [PATCH 3/4] [VAR] Move unsetvar functionality into setvareq Herbert Xu
2010-05-26 11:00                   ` [PATCH 4/4] [VAR] Replace cmdenviron with localvars Herbert Xu
2010-05-26 22:37                     ` Jilles Tjoelker [this message]
2010-05-27  3:51                       ` Herbert Xu
2010-05-29 13:45                         ` Jilles Tjoelker

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=20100526223723.GB5679@stack.nl \
    --to=jilles@stack.nl \
    --cc=dash@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=pape@smarden.org \
    /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