title: How to avoid command substitution in Tcl strings?
body: <p>I'm trying to write an expect script, which is based on Tcl. (actually I'm trying to generate expect scripts in python, and no, I can't use pyexpect)</p>
  
  <p>How can I send a string without special characters (like <code>[</code>) being interpreted as commands?</p>
  
  <p>In bash shell, I can use single quotes to write raw strings.</p>
  
  <pre><code>$ echo 'hello $world'
  hello $world
  </code></pre>
  
  <p>But with expect, I have many problems with special characters. For example, brackets are interpreted as commands.</p>
  
  <pre><code>expect1.1&gt; send_user "[hello]"
  invalid command name "hello"
      while executing
  "hello"
  </code></pre>
  
  <p>How can I just print the string "[hello]"?</p>
  
  <p>EDIT: just enclosing a string in curly braces doesn't always work.</p>
  
  <p>For example</p>
  
  <p>expect1.4> send_user {h}ello}</p>
  
  <p>doesn't print the string "h}ello". It gives an error:</p>
  
  <pre><code>extra characters after close-brace
      while executing
  "send {h}ello}
  </code></pre>
  
  <p><strong>And there is no way to escape the curly braces according to the doc.</strong></p>
  
  <p>Or what if I want to send a string starting with *} ? Rule 5 in <a href="http://tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M10" rel="nofollow">http://tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M10</a> will interfere and no way to escape the * or the }.</p>