Le 20/01/2021 à 12:16, Oğuz écrivait :
$ 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 assignation part:
a is assigned X but it is stored as x in a.
The value of parameter is then substituted.
The expansion part:
The value X is expanded but is not affected by the lowercase
transformation flag from a, so it remains as X.
The fact that an expansion also assign a value is a questionable design
choice though.
If I had to use this I would just silence the expansion as an argument
to the dummy true or : command
: ${a:=X}
Is this a bug or am I missing something here?
Then likely not.
--
Léa Gris