title: Bash array of strings with space character as executable parameters
body: <p>There is this code:</p>
  
  <p>test2.cpp (compiled to test2 executable):</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main(int argc, char** argv)
  {
     for(int i = 0; i &lt; argc; ++i){
        std::cout &lt;&lt; i &lt;&lt; " " &lt;&lt; argv[i] &lt;&lt; std::endl;
     }
     return 0;
  }
  </code></pre>
  
  <p>test.sh (parameters preparing script):</p>
  
  <pre><code>some_array=("text1" "text two" "text tree")
  
  input_variables=""
  
  for i in $(seq 0 $((${#some_array[*]} - 1))); do
     input_variables="$input_variables --parameter=\"${some_array[$i]}\""
     echo $input_variables
  done
  
  echo "Running: ./test2$input_variables"
  ./test2 $input_variables
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>$ sh test.sh
  --parameter="text1"
  --parameter="text1" --parameter="text two"
  --parameter="text1" --parameter="text two" --parameter="text tree"
  Running: ./test2 --parameter="text1" --parameter="text two" --parameter="text tree"
  0 ./test2
  1 --parameter="text1"
  2 --parameter="text
  3 two"
  4 --parameter="text
  5 tree"
  </code></pre>
  
  <p>I would like to pass to <em>test2</em> executable 3 arguments but 5 arguments are passed and there is a problem with space character between words. I would like also to keep input parameters in array like it is presented in *some_array* so I can add there something whenever I want. How to pass these parameters correctly?</p>