How do you return an array in bash?

Nguyễn Pháp

New member
How do you return an array in bash?
Answer
This approach involves the following three steps:
  1. Convert the array with ‘declare -p’ and save the output in a variable. …
  2. Use the echo builtin to pass the variable to a function or to pass it back from there. …
  3. Finally, recreate the array where it is passed to using the eval and the ‘declare -a’ builtins.
 

Tìm kiếm

Back
Top