All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Dan Kegel <dank@kegel.com>, dash@vger.kernel.org
Subject: Re: eval and export behave differently together in dash and ash than in bash, zsh, and ksh
Date: Fri, 14 Feb 2014 11:46:31 -0700	[thread overview]
Message-ID: <52FE6487.7000202@redhat.com> (raw)
In-Reply-To: <CAPF-yOaxN0b3t-H8Vi3HirpAuV0gsdu9XWROws4o02JXAEdzAA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1464 bytes --]

On 02/14/2014 11:29 AM, Dan Kegel wrote:
> The script
> 
> eval export dir=~$LOGNAME
> echo $dir

This has been discussed by the POSIX folks.  See:
http://austingroupbugs.net/view.php?id=351

The standard added the definition of a 'declaration utility', which can
evaluate its arguments in assignment context, and marked that 'export'
is one such utility:

>> At line 74276 (XCU export DESCRIPTION), add:
>> The export special built-in shall be a declaration utility. Therefore,
>> if export is recognized as the command word of a simple command, then
>> subsequent words of the form name=word shall be expanded in an
>> assignment context. See Section 2.9.1.

Meanwhile, 'eval' is not allowed to be a declaration utility.  Thus,
once this POSIX interpretation is made live in Issue 8 (currently still
unreleased), a conforming shell would have to evaluate this as:

eval export dir=~$LOGNAME      # not in assignment context
eval 'export' 'dir=~buildbot'  # actual arguments passed to eval
export dir=~buildbot           # declaration context, do tilde expansion
dir gets /home/buildbot

ksh and bash are compliant, dash needs to be patched.

However, as Issue 8 POSIX is not yet released, dash is not yet
non-compliant, and you are correct that workarounds exist while waiting
for someone to write the patch for dash.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

      reply	other threads:[~2014-02-14 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14 18:29 eval and export behave differently together in dash and ash than in bash, zsh, and ksh Dan Kegel
2014-02-14 18:46 ` Eric Blake [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=52FE6487.7000202@redhat.com \
    --to=eblake@redhat.com \
    --cc=dank@kegel.com \
    --cc=dash@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.