I'm still puzzling together the pieces to trace fossils output and inject the appropriate answers. Now an other problem raised its ugly head.

When fossil prompts the user for input, it waits for the answer on the same line as the prompt. It doesn't add a line end terminator after the prompt.
The problem is that I need to read the fossil output before I can decide what to do. I do this by registering to events which occur whenever a line has been written to stdout or stderr. Unfortunately the line isn't written completely for prompts, the line end terminator is missing. Because of this, the line is never read, the event is never fired and the answer is never sent to stdin to make fossil happy. Fossil waits forever.

A minor change in user.c would make it possible to read the line. Just add a newline to the format string in the printf statement and anything should work.
<pre>
void prompt_user(const char *zPrompt, Blob *pIn){
  char *z;
  char zLine[1000];
  blob_zero(pIn);
  printf("%s\n", zPrompt); /* added a newline to terminate the line */
  fflush(stdout);
  z = fgets(zLine, sizeof(zLine), stdin);
  if( z ){
    strip_string(pIn, z);
  }
}
</pre>
I think except for the input in the user_cmd function it doesn't really matter wether the response is entered on a new line or not and even there it is not really a problem.