help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: local -r for arrays


From: João Eiras
Subject: Re: local -r for arrays
Date: Sun, 25 Oct 2020 22:27:27 +0100

Interesting.

Reduced example:

function tt {
  set -x
  local -r a=1
  local -r b=(1)
  local -r c=$(echo 1)
}
}
tt

This prints

+ local -r a=1
+ b=(1)
+ local -r b
++ echo 1
+ local -r c=1

So, when creating a variable when a simple value, the statement is
evaluated as a whole, but when setting an array, it splits into value
assignment and then variable declaration.
I have no idea why this is the case.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]