Is there a way to join (with proper quoting and escaping) a bash array such that it gives me a string suitable for passing to bash -c?
Reason:
I want to write a function foo, such that when I do this:
foo app "hello world.txt"
it'll do this:
sudo -u myuser ENVVAR=somevalue bash -c "perl app \"hello world.txt\""