antonio wrote:
#!/bin/bash
a=( 1 2 3 )
b=( 4 5 6 )
x=a
eval b=( [EMAIL PROTECTED] )
echo [EMAIL PROTECTED]
#output:
#1 2 3
x=b
eval $x=( [EMAIL PROTECTED] )
#output:
#./tst: line 15: syntax error near unexpected token `('
#./tst: line 15: `eval $x=( [EMAIL PROTECTED] ) '
Strictly speaking, these are both syntax errors (unescaped metacharacters,
etc.).
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
one.
By the way, it's bad form to conceal your address and expect a response.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://cnswww.cns.cwru.edu/~chet/