mighty-gerbils / gerbil

Gerbil Scheme
https://cons.io
GNU Lesser General Public License v2.1
1.14k stars 112 forks source link

Default output in gxi -e is not flushed #1064

Closed leahneukirchen closed 7 months ago

leahneukirchen commented 7 months ago

Print one line:

% gxi -e '(displayln "foo")' | wc -l
0

Explicit flushing helps:

% gxi -e '(displayln "foo")' -e '(flush-output-port)' | wc -l
1

I think the Gerbil runtime should flush (all?) ports on exit.

vyzo commented 7 months ago

yes, and the executables should too.

fare commented 7 months ago

So (1) fix things with an unwind-protect in src/gerbil/main.ss#main, but I'm not sure what is step (2).

vyzo commented 7 months ago

I think we also need to do it in the executable main we generate in the compiler, it is called gerbil-main and it happens in the driver.

fare commented 7 months ago

Stupid question: (force-output (current-output-port)) before or after (force-output (current-error-port)) ? And withinwith-catch void each, innit?

vyzo commented 7 months ago

output before error seems more reasonable.

with-catch might be unnessary for the flush, but cant hurt.