Author: Stan Eisenstat
Subject: Re: [Cs323] Assignment when is defined
Date: Tuesday, 13 Oct 2020, 07:59:18
> Message Posted By: Unknown > > When i execute the command sequences > > % /c/cs323/Hwk3/mcBash > (1)$ ${ONE=1} > >> 1 > (2)$ ${TWO=${ONE=${ZERO=0}}} > >> 1 > (3)$ $TWO > >> 1 > > It seems TWO is still being assigned the value of ONE, even though ONE was > previously defined. However the spec says "However, if NAME exists, then > during the expansion mcBash must suppress any assignments to environment > variables...", so I was expecting TWO to have no value, since the > assignment to ONE will cause assignments to be suppressed. Can you please > explain this? Since ONE is undefined, "${ONE=1}" sets ONE to "1" and is replaced by "1". Since TWO is undefined, "${TWO=${ONE=${ZERO=0}}}" sets TWO to the value of "${ONE=${ZERO=0}}" and is replaced by it. Since ONE is defined as "1", "${ONE=${ZERO=0}}" does not change the value of ONE and its value is also "1". Moreover, it does not assign a value to ZERO. --Stan-PREV INDEX NEXT