title: Shell variable with spaces , quoting for single command line option
body: <p>Autoconf scripts have trouble with a filename or pathname with spaces.  For example,</p>
  
  <pre><code>./configure CPPFLAGS="-I\"/path with space\""
  </code></pre>
  
  <p>results in (config.log):</p>
  
  <pre><code>configure:3012: gcc  -I"/path with space"  conftest.c  &gt;&amp;5
  gcc: with: No such file or directory
  gcc: space": No such file or directory
  </code></pre>
  
  <p>The compile command from ./configure is <code>ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext &gt;&amp;5'</code> and I am not able to modify this (I could perhaps, but working around autoconf in this way is not a general solution).</p>
  
  <p>I think it comes down to getting a shell variable that contains spaces to be parsed as a single command line variable rather than split at spaces.  The simplest shell example I can come up with is to create a file with spaces and attempt to list is with <code>ls</code> with a shell variable as the argument to <code>ls</code>:</p>
  
  <pre><code>$ touch "a b"
  $ file="a b"
  $ ls $file
  ls: a: No such file or directory
  ls: b: No such file or directory
  </code></pre>
  
  <p>This works, but is illegal since in autoconf I can't modify the shell code:</p>
  
  <pre><code>$ ls "$file"
  a b
  </code></pre>
  
  <p>None of the following attempts at quoting things work:</p>
  
  <pre><code>$ file="\"a \"b"; ls $file
  ls: "a: No such file or directory
  ls: b": No such file or directory
  $ file="a\ b"
  $ file="a\\ b"
  $ file="`echo \\"a b\\"`"
  </code></pre>
  
  <p>and so on.</p>
  
  <p>Is this impossible to accomplish in shell scripts?  Is there a magical quoting that will expand a shell variable with spaces into a single command line argument?</p>