* Re: eval and export behave differently together in dash and ash than in bash, zsh, and ksh
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
0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2014-02-14 18:46 UTC (permalink / raw)
To: Dan Kegel, dash
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread