$ {! name: = val} does not specify $ name?

According to the bash manual ,! implies that the value of val1 should be used as a parameter for the extension. So why is val2 not set to β€œtext” after line 6?

echo ${val1:-"val1 not set"} # val1 not set
echo ${val1:="val2"} # val1=val2
echo ${val1+"val1 set"} #check that val1 is set
echo ${!val1:-"val 2 not set"} # val2 not set
echo ${!val1:="text"} #  val 2 should be set? 
echo ${!val1:-"val2 not set"} # val2 empty
echo ${val2:-"val2 not set"} # val2 empty
val2="val2 set"  # val2 set from here on
echo ${!val1:-"val2 not set"} 
echo ${val2:-"val2 not set"}
+4
source share
1 answer

This seems to be fixed in bash4.4:

$ bash/bash tmp.bash
val1 not set
val2
val1 set
val 2 not set
text
text             <------ Line 6 now outputs text
text             <------ As does line 7
val2 set
val2 set

( bash/- my local working directory of the Git repository, it contains local assembly 4.4.)

+4
source

All Articles