0

I have my array of arguments "$@" that I would like to reuse in an other process.

Basically what I want is a way to say :

string="$(save_array "$@")"
# save string to a file

And in another process:

# load string from file
arr="$(load_array "$string")"

All solutions I found on stackoverflow seemed to lose some information (eg would not work if some of the items in the array contain newlines or \0 character.

It is OK if the solution uses well known programs (grep/sed/python), but not something not installed on a base system.

edi9999
  • 19,701
  • 13
  • 88
  • 127
  • Can array elements actually contain `\0` in bash? That would surprise me. – melpomene Oct 03 '17 at 06:18
  • Yes, it also seems from my tests that it is not possible to have \0 in arrays. It seems that the second proposition in https://stackoverflow.com/a/18860477/1993501 works for me – edi9999 Oct 03 '17 at 06:42

0 Answers0