On 7/26/22 11:48, kf wrote:
Yes, I was aware that another process started with "while...". But is there no way to specify a variable type which can access that other process? There can be merit in isolating variables, even when they have the same name, but as my case here shows, there are also times when a variable's value should be accessible throughout the body of code, e.g., when in C a global or static variable is used. Is that simply impossible in bash?
No, bash variables are untyped. You can hint to the interpreter that you want to consider a variable of type int, e.g. declare -i myint Or array, declare -a myarray Or associative array declare -A array Or a nameref (similar to old indirect access) declare -n mytyperef But those are just hints, nothing prevents myint="mystring". It's up to you to know what is held by each variable. There are ways to test if what is held is an int, etc.. but those are also things you implement. -- David C. Rankin, J.D.,P.E.