[Top][All Lists]

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

Re: eval, apparently inconsistent behavior

From: Chet Ramey
Subject: Re: eval, apparently inconsistent behavior
Date: Sun, 08 Jun 2008 22:32:50 -0400
User-agent: Thunderbird (Macintosh/20080421)

antonio wrote:

a=( 1 2 3 )
b=( 4 5 6 )

eval b=( address@hidden )
echo address@hidden

#1 2 3

eval $x=( address@hidden )

#./tst: line 15: syntax error near unexpected token `('
#./tst: line 15: `eval $x=( address@hidden ) '

Strictly speaking, these are both syntax errors (unescaped metacharacters,

Bash tries to detect words that appear to be assignment statements
in arguments to builtin commands that accept assignments (declare, eval,
local, export, and so on).  When it detects such an argument, it attempts
to treat it like an assignment statement preceding a simple command:
parsing compound assignments specially, no word splitting, no glob
expansion, etc.

You can fool this, especially in the case of `eval', as you discovered.
The argument to eval in the second assignment doesn't look like an
assignment statement to the parser, so it doesn't try to treat it like

By the way, it's bad form to conceal your address and expect a response.

``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]