title: Understand shell script interpreter with custom shell
body: <p>I try to understood how shell script interpreter working.<br />
  for example i wrote custom shell with c++ :</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std ;
  
  int main()
  {
      string input;
      while (1)
      {
          cout &lt;&lt; &quot;prompt:&gt; &quot;;
          cin &gt;&gt; input;
          if(input==&quot;exit&quot;)
              return 0;
          else if(input==&quot;test&quot;)
              cout &lt;&lt; &quot;You executed test command\n&quot;;
          else
              cout &lt;&lt; &quot;Unknown command.\n&quot;;
      }
  }
  </code></pre>
  <p>now i wrote a script like this :</p>
  <pre><code>#!/PATH/TO/COMPILED/SHELL 
  test
  wrong_command1 
  wrong_command2
  exit    
  </code></pre>
  <p>Actually this script not working and i want to understand what part of my thinking is wrong .<br />
  <strong>Note:</strong> I executed this script on <code>/bin/bash</code> shell .</p>
  <ol>
  <li>can i say ,my c++ code is: <code>interactive shell</code></li>
  <li>How interpreters work on shell scripts ?  <code>#!/PATH/TO/COMPILED/SHELL</code></li>
  <li>How can fix code or script to activate interpreting feature ?</li>
  </ol>