title: Why the CMD/Cygwin shell does not return after WinExec?
body: <p>The Delphi console application in question tries to utilize <code>WinExec</code> to call <code>Cygwin</code>'s <code>echo.exe</code> to output with color. <code>Cygwin</code> is installed under <code>C:\cygwin</code>. Its <code>echo.exe</code> is <code>C:\cygwin\bin\echo.exe</code>.</p>
  
  <p>The reason to choose <code>WinExec</code> over <code>ShellExecute</code> is <code>ShellExecute</code> will instantiate a new shell and echo the texts in that new shell.</p>
  
  <p>The same behavior occurs when I invoke the console application within Windows' CMD shell.</p>
  
  <h2>First attempt</h2>
  
  <p><img src="https://i.stack.imgur.com/wZBZv.png" alt="picture of the first attempt"></p>
  
  <p>As shown in the picture, the shell does not return to the prompt. I though WinExec does not finish or need another carriage.</p>
  
  <pre><code>program TestConsole;
  
  {$APPTYPE CONSOLE}
  
  uses
    SysUtils, Windows;
  
  begin
    WinExec('C:\cygwin\bin\echo.exe -e "\e[1;34mColored text.\e[0m"', SW_NORMAL);
  end.
  </code></pre>
  
  <h2>Second attempt</h2>
  
  <p><img src="https://i.stack.imgur.com/68PwO.png" alt="picture of the second attempt"></p>
  
  <p>As shown in the picture, it is clear that WinExec already finish. But the shell still does not return to the prompt. I am confused about the reason. Could you help to comment? Any comment will be appreciated!!</p>
  
  <pre><code>program TestConsole;
  
  {$APPTYPE CONSOLE}
  
  uses
    SysUtils, Windows;
  
  var
    I: Integer;
  begin
    I := WinExec('C:\cygwin\bin\echo.exe -e "\e[1;34mColored text.\e[0m"', SW_NORMAL);
    Writeln(IntToStr(I));
  end.
  </code></pre>