title: Bash inconsistent escaping of asterisk * in expect?
body: <p>I've got 2 expect commands, however, I don't understand the expansion that's going on. (In context, I have a script that connects to a server, downloads and blanks all the log files in a specified directory.)</p>
  
  <pre><code>expect -c "
      set timeout 1
      spawn scp user@hostname:/logdir/\*.log .
      expect yes/no { send yes\n ; exp_continue }
      expect password: { send $pass\n }
      expect 100%
      sleep 1
      exit
  ";
  </code></pre>
  
  <p>In this command, expect displays the spawned command as <code>spawn scp user@hostname:/logdir/*.log .</code> Which means that the \ was removed.</p>
  
  <pre><code>expect -c "
      set timeout 1
      spawn ssh user@hostname {echo '' | tee /logdir/\*.log &gt; /dev/null}
      expect yes/no { send yes\n ; exp_continue }
      expect password: { send $pass\n }
      expect eof
  ";
  </code></pre>
  
  <p>In this command, expect displays the spawned command as <code>spawn ssh user@hostname echo '' | tee /logdir/\*.log &gt; /dev/null</code> Which means that the \ was <em>not</em> removed. Why is it different? (If I don't escape the asterisk, like <code>tee /logdir/*.log</code>, it does work. But I don't understand what is working differently from the above case?)</p>