On 1/20/21 6:16 AM, Oğuz wrote:
$ declare -l a
$ echo "${a:=X} $a"
X x
This doesn't jive with what the manual says.
`-l`:
When the variable is assigned a value, all upper-case characters are
converted to lower-case.
`:=`:
If parameter is unset or null, the expansion of word is assigned to
parameter. The value of parameter is then substituted.
Is this a bug or am I missing something here?
Thanks for the report. It's probably not what you intend, but it's the way
bash has done things all the way back to bash-4.0 when the additional
variable attributes were introduced (and further back if you consider the
integer attribute).
The way bash does it is that the word is expanded (to `X') and that value
is assigned to a. That becomes the value of the expansion. The conversion
is then performed, at a lower layer, on the assignment.
This should only affect this particular parameter expansion involving
variables where this kind of conversion takes place at assignment time. I
think it would be reasonable to change the result to the final value of
the variable for the next version and make the new behavior dependent on
the shell compatibility level.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/