Because shells other than ksh do not support pass-by-reference, how can multiple arrays be passed into a function in bash without using global variables, and in a way which allows any legal variable content to be included as an array element (no reserved sigils)?
Because shells other than ksh do not support pass-by-reference, how can multiple arrays be
Share
Since bash 4.3
As of 2016, modern bash supports pass-by-reference (a.k.a
namerefattribute) as:See also
declare -nin the man page.Before bash 4.3
This can be done safely by using a calling convention which puts number-of-arguments before each array, as such:
This can then be called as follows: