Re: some more inline assignments / evaluation wrt POSIX
Mike Frysinger wrote: > testing with bash-3.2p17 here ... > > looking at these statements: > K=dvb0.net A=${K#dvb} echo "$A" > K=dvb0.net A=${K#dvb} ; echo "$A" > K=dvb0.net A=${K#dvb} eval echo '$A' > > shouldnt "0.net" always be displayed ? looks like A is always set properly > to "0.net", but in the first statement, $A gets expanded before the variable > assignments are processed As Andreas said, variable assignments preceding a command name are deferred until the rest of the words in the command are expanded. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. No day but today. Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://cnswww.cns.cwru.edu/~chet/ ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: variable assignments and parameter expansion in a single command
Kevin F. Quinn wrote: > 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' This is a bug in bash. There are certain circumstances where the expansion of A will refer to the wrong version of $K. It's state- dependent, so it's been missed so far. I fixed it today. In general, expansions of assignment statements destined for the temporary environment should check for variables in the temporary environment before the normal shell variable table. That preserves the left-to-right processing order. > $ bash -c 'a=/bin PATH=$a ls /dev/null' > bash: line 1: ls: No such file or directory This is the same problem as the first case. > $ bash -c 'x=${K:=dvb0.net0} A=${K#dvb} echo $A' This behaves correctly. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. No day but today. Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://cnswww.cns.cwru.edu/~chet/ ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash