Re: eval and export behave differently together in dash and ash than in bash, zsh, and ksh

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

 



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: signature.asc
Description: OpenPGP digital signature


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

  Powered by Linux