Re: variable assignments and parameter expansion in a single command
From:
Kevin F. Quinn
Subject:
Re: variable assignments and parameter expansion in a single command
Date:
Sat, 19 May 2007 00:12:57 +0200
Following a discussion we had earlier this year regarding the order of
evaluation of variables and variable assignments:
$ A="moo" B="$A more" env |grep ^B
B=moo more
(rather than showing just 'B= more')
the dash maintainer has highlighted the following:
$ bash -c 'K=dvb0.net0 A=${K#dvb} eval echo \$A'
$ bash -c 'a=/bin PATH=$a ls /dev/null'
bash: line 1: ls: No such file or directory
$ bash -c 'x=${K:=dvb0.net0} A=${K#dvb} echo $A'
$
which he says is inconsistent. I could see the third one is correct
(variable assignments are evaluated after expansion, according to the
spec), but can't see whether the first two are correct or not.
Is the bash behaviour correct in these cases?
Cheers,
Kev.