fork download
  1. #!/bin/bash
  2. arr1=( '$(rm -rf ~)' 'hello cruel world' )
  3. arr2=( ' * suffix number 1 * ' 'suffix,with,commas' )
  4.  
  5. set -x
  6. printf -v arr1_str '%q,' "${arr1[@]}"; arr1_str=${arr1_str%,}
  7. printf -v arr2_str '%q,' "${arr2[@]}"; arr2_str=${arr2_str%,}
  8. eval "printf '%s\n' {${arr1_str}}{${arr2_str}}"
Success #stdin #stdout #stderr 0s 4472KB
stdin
Standard input is empty
stdout
$(rm -rf ~) * suffix number 1 * 
$(rm -rf ~)suffix,with,commas
hello cruel world * suffix number 1 * 
hello cruel worldsuffix,with,commas
stderr
+ printf -v arr1_str %q, '$(rm -rf ~)' 'hello cruel world'
+ arr1_str='\$\(rm\ -rf\ ~\),hello\ cruel\ world'
+ printf -v arr2_str %q, ' * suffix number 1 * ' suffix,with,commas
+ arr2_str='\ \*\ suffix\ number\ 1\ \*\ ,suffix\,with\,commas'
+ eval 'printf '\''%s\n'\'' {\$\(rm\ -rf\ ~\),hello\ cruel\ world}{\ \*\ suffix\ number\ 1\ \*\ ,suffix\,with\,commas}'
++ printf '%s\n' '$(rm -rf ~) * suffix number 1 * ' '$(rm -rf ~)suffix,with,commas' 'hello cruel world * suffix number 1 * ' 'hello cruel worldsuffix,with,commas'